org.mortbay.jetty
Class Server
java.lang.Object
org.mortbay.component.AbstractLifeCycle
org.mortbay.jetty.handler.AbstractHandler
org.mortbay.jetty.handler.HandlerCollection
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
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
Server
public Server()
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.