org.mortbay.jetty
Class Server

java.lang.Object
  extended by org.mortbay.component.AbstractLifeCycle
      extended by org.mortbay.jetty.handler.AbstractHandler
          extended by org.mortbay.jetty.handler.AbstractHandlerContainer
              extended by org.mortbay.jetty.handler.HandlerWrapper
                  extended by org.mortbay.jetty.Server
All Implemented Interfaces:
LifeCycle, Handler, HandlerContainer, Attributes

public class Server
extends HandlerWrapper
implements Attributes

Jetty HTTP Servlet Server. This class is the main class for the Jetty HTTP Servlet server. It aggregates Connectors (HTTP request receivers) and request Handlers. The server is itself a handler and a ThreadPool. Connectors use the ThreadPool methods to run jobs that will eventually call the handle method.


Field Summary
 
Fields inherited from class org.mortbay.jetty.handler.AbstractHandler
_string
 
Fields inherited from interface org.mortbay.jetty.Handler
ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST
 
Constructor Summary
Server()
           
Server(int port)
          Convenience constructor Creates server and a SocketConnector at the passed port.
 
Method Summary
 void addConnector(Connector connector)
           
 void addHandler(Handler handler)
          Add a handler.
 void addLifeCycle(LifeCycle c)
          Add a LifeCycle object to be started/stopped along with the Server.
 void addUserRealm(UserRealm realm)
           
 void clearAttributes()
           
protected  void doStart()
           
protected  void doStop()
           
 Object getAttribute(String name)
           
 Enumeration getAttributeNames()
           
 Connector[] getConnectors()
           
 Container getContainer()
           
 Handler[] getHandlers()
           
 boolean getSendServerVersion()
           
 SessionIdManager getSessionIdManager()
           
 boolean getStopAtShutdown()
           
 ThreadPool getThreadPool()
           
 UserRealm[] getUserRealms()
           
 String getVersion()
           
 void handle(HttpConnection connection)
           
 void join()
           
 void removeAttribute(String name)
           
 void removeConnector(Connector connector)
          Conveniance method which calls getConnectors() and setConnectors(Connector[]) to remove a connector.
 void removeHandler(Handler handler)
           
 void removeLifeCycle(LifeCycle c)
          Remove a LifeCycle object to be started/stopped along with the Server
 void removeUserRealm(UserRealm realm)
           
 void setAttribute(String name, Object attribute)
           
 void setConnectors(Connector[] connectors)
          Set the connectors for this server.
 void setHandlers(Handler[] handlers)
           
 void setSendServerVersion(boolean sendServerVersion)
           
 void setSessionIdManager(SessionIdManager sessionIdManager)
           
 void setStopAtShutdown(boolean stop)
           
 void setThreadPool(ThreadPool threadPool)
           
 void setUserRealms(UserRealm[] realms)
           
 
Methods inherited from class org.mortbay.jetty.handler.HandlerWrapper
expandChildren, getHandler, handle, setHandler, setServer
 
Methods inherited from class org.mortbay.jetty.handler.AbstractHandlerContainer
expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
 
Methods inherited from class org.mortbay.jetty.handler.AbstractHandler
destroy, getServer, toString
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mortbay.component.LifeCycle
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop
 

Constructor Detail

Server

public Server()

Server

public Server(int port)
Convenience constructor Creates server and a SocketConnector at the passed port.

Method Detail

getContainer

public Container getContainer()
Returns:
Returns the container.

getStopAtShutdown

public boolean getStopAtShutdown()

setStopAtShutdown

public void setStopAtShutdown(boolean stop)

getConnectors

public Connector[] getConnectors()
Returns:
Returns the connectors.

addConnector

public void addConnector(Connector connector)

removeConnector

public void removeConnector(Connector connector)
Conveniance method which calls getConnectors() and setConnectors(Connector[]) to remove a connector.

Parameters:
connector - The connector to remove.

setConnectors

public void setConnectors(Connector[] connectors)
Set the connectors for this server. Each connector has this server set as it's ThreadPool and its Handler.

Parameters:
connectors - The connectors to set.

getThreadPool

public ThreadPool getThreadPool()
Returns:
Returns the threadPool.

setThreadPool

public void setThreadPool(ThreadPool threadPool)
Parameters:
threadPool - The threadPool to set.

doStart

protected void doStart()
                throws Exception
Overrides:
doStart in class HandlerWrapper
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Overrides:
doStop in class HandlerWrapper
Throws:
Exception

handle

public void handle(HttpConnection connection)
            throws IOException,
                   ServletException
Throws:
IOException
ServletException

join

public void join()
          throws InterruptedException
Throws:
InterruptedException

getUserRealms

public UserRealm[] getUserRealms()
Returns:
Map of realm name to UserRealm instances.

setUserRealms

public void setUserRealms(UserRealm[] realms)
Parameters:
realms - Map of realm name to UserRealm instances.

addUserRealm

public void addUserRealm(UserRealm realm)

removeUserRealm

public void removeUserRealm(UserRealm realm)

getSessionIdManager

public SessionIdManager getSessionIdManager()
Returns:
Returns the sessionIdManager.

setSessionIdManager

public void setSessionIdManager(SessionIdManager sessionIdManager)
Parameters:
sessionIdManager - The sessionIdManager to set.

setSendServerVersion

public void setSendServerVersion(boolean sendServerVersion)

getSendServerVersion

public boolean getSendServerVersion()

getVersion

public String getVersion()

addLifeCycle

public void addLifeCycle(LifeCycle c)
Add a LifeCycle object to be started/stopped along with the Server.

Parameters:
c -

removeLifeCycle

public void removeLifeCycle(LifeCycle c)
Remove a LifeCycle object to be started/stopped along with the Server

Parameters:
c -

addHandler

public void addHandler(Handler handler)
Description copied from class: HandlerWrapper
Add a handler. This implementation of addHandler calls setHandler with the passed handler. If this HandlerWrapper had a previous wrapped handler, then it is passed to a call to addHandler on the passed handler. Thus this call can add a handler in a chain of wrapped handlers.

Specified by:
addHandler in interface HandlerContainer
Overrides:
addHandler in class HandlerWrapper

removeHandler

public void removeHandler(Handler handler)

getHandlers

public Handler[] getHandlers()

setHandlers

public void setHandlers(Handler[] handlers)

clearAttributes

public void clearAttributes()
Specified by:
clearAttributes in interface Attributes

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface Attributes

getAttributeNames

public Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface Attributes

removeAttribute

public void removeAttribute(String name)
Specified by:
removeAttribute in interface Attributes

setAttribute

public void setAttribute(String name,
                         Object attribute)
Specified by:
setAttribute in interface Attributes