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.HandlerCollection
              extended by org.mortbay.jetty.Server
All Implemented Interfaces:
LifeCycle, Handler

public class Server
extends HandlerCollection

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.

Author:
gregw

Nested Class Summary
private static class Server.ShutdownHookThread
          ShutdownHook thread for stopping all servers.
 
Field Summary
private  Connector[] _connectors
           
private  Container _container
           
private  PathMap _contextMap
           
private  Handler _notFoundHandler
           
private  UserRealm[] _realms
           
private  RequestLog _requestLog
           
private  ThreadPool _threadPool
           
private static Server.ShutdownHookThread hookThread
           
 
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()
           
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
private  void expandHandler(Handler handler, List list)
           
 Handler[] getAllHandlers()
           
 Connector[] getConnectors()
           
 Container getContainer()
           
 Handler getNotFoundHandler()
           
 RequestLog getRequestLog()
           
 boolean getStopAtShutdown()
           
 ThreadPool getThreadPool()
           
 UserRealm[] getUserRealms()
           
 void handle(HttpConnection connection)
           
 boolean handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
          Generic Jetty request handler.
 void join()
           
 void setConnectors(Connector[] connectors)
          Set the connectors for this server.
 void setHandlers(Handler[] handlers)
           
 void setNotFoundHandler(Handler notFoundHandler)
           
 void setRequestLog(RequestLog requestLog)
           
 void setStopAtShutdown(boolean stop)
           
 void setThreadPool(ThreadPool threadPool)
           
 void setUserRealms(UserRealm[] realms)
           
 
Methods inherited from class org.mortbay.jetty.handler.HandlerCollection
addHandler, getHandler, getHandlers, removeHandler, setHandler, setServer
 
Methods inherited from class org.mortbay.jetty.handler.AbstractHandler
getServer, toString
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
isFailed, isRunning, isStarted, isStarting, 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.jetty.Handler
getServer
 
Methods inherited from interface org.mortbay.component.LifeCycle
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop
 

Field Detail

hookThread

private static Server.ShutdownHookThread hookThread

_threadPool

private ThreadPool _threadPool

_connectors

private Connector[] _connectors

_realms

private UserRealm[] _realms

_notFoundHandler

private Handler _notFoundHandler

_container

private Container _container

_requestLog

private RequestLog _requestLog

_contextMap

private PathMap _contextMap
Constructor Detail

Server

public Server()
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.

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.

setHandlers

public void setHandlers(Handler[] handlers)
Overrides:
setHandlers in class HandlerCollection
Parameters:
handlers - The handlers to set.

getThreadPool

public ThreadPool getThreadPool()
Returns:
Returns the threadPool.

setThreadPool

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

setRequestLog

public void setRequestLog(RequestLog requestLog)
Parameters:
requestLog -

getRequestLog

public RequestLog getRequestLog()
Returns:

doStart

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

doStop

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

handle

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

handle

public boolean handle(String target,
                      HttpServletRequest request,
                      HttpServletResponse response,
                      int dispatch)
               throws IOException,
                      ServletException
Description copied from interface: Handler
Generic Jetty request handler.

Specified by:
handle in interface Handler
Overrides:
handle in class HandlerCollection
Parameters:
target - The target of the request - either a URI or a name.
request - The request either as the Request object or a wrapper of that request. The HttpConnection.getCurrentConnection() method can be used access the Request object if required.
response - The response as the Response object or a wrapper of that request. The HttpConnection.getCurrentConnection() method can be used access the Response object if required.
dispatch - The dispatch mode: Handler.REQUEST, Handler.FORWARD, Handler.INCLUDE, Handler.ERROR
Returns:
True if the request has been handled
Throws:
IOException
ServletException

getAllHandlers

public Handler[] getAllHandlers()

expandHandler

private void expandHandler(Handler handler,
                           List list)

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.

getNotFoundHandler

public Handler getNotFoundHandler()
Returns:
Returns the notFoundHandler.

setNotFoundHandler

public void setNotFoundHandler(Handler notFoundHandler)
Parameters:
notFoundHandler - The notFoundHandler to set.