org.eclipse.jetty.servlet
Class ServletContextHandler

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.server.handler.AbstractHandler
          extended by org.eclipse.jetty.server.handler.AbstractHandlerContainer
              extended by org.eclipse.jetty.server.handler.HandlerWrapper
                  extended by org.eclipse.jetty.server.handler.ScopedHandler
                      extended by org.eclipse.jetty.server.handler.ContextHandler
                          extended by org.eclipse.jetty.servlet.ServletContextHandler
All Implemented Interfaces:
Handler, CompleteHandler, HandlerContainer, Server.Graceful, Attributes, LifeCycle
Direct Known Subclasses:
WebAppContext

public class ServletContextHandler
extends ContextHandler

Servlet Context. This extension to the ContextHandler allows for simple construction of a context with ServletHandler and optionally session and security handlers, et.

   new ServletContext("/context",Context.SESSIONS|Context.NO_SECURITY);
 

This class should have been called ServletContext, but this would have cause confusion with ServletContext.


Nested Class Summary
 class ServletContextHandler.Context
           
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
Field Summary
protected  Class<? extends SecurityHandler> _defaultSecurityHandlerClass
           
protected  int _options
           
protected  SecurityHandler _securityHandler
           
protected  ServletHandler _servletHandler
           
protected  SessionHandler _sessionHandler
           
static int NO_SECURITY
           
static int NO_SESSIONS
           
static int SECURITY
           
static int SESSIONS
           
 
Fields inherited from class org.eclipse.jetty.server.handler.ContextHandler
_scontext, MANAGED_ATTRIBUTES
 
Fields inherited from class org.eclipse.jetty.server.handler.ScopedHandler
_nextScope, _outerScope
 
Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
_handler
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Fields inherited from interface org.eclipse.jetty.server.handler.CompleteHandler
COMPLETE_HANDLER_ATTR
 
Constructor Summary
ServletContextHandler()
           
ServletContextHandler(HandlerContainer parent, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
           
ServletContextHandler(HandlerContainer parent, String contextPath)
           
ServletContextHandler(HandlerContainer parent, String contextPath, boolean sessions, boolean security)
           
ServletContextHandler(HandlerContainer parent, String contextPath, int options)
           
ServletContextHandler(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
           
ServletContextHandler(int options)
           
 
Method Summary
 FilterHolder addFilter(Class<? extends Filter> filterClass, String pathSpec, int dispatches)
          convenience method to add a filter
 void addFilter(FilterHolder holder, String pathSpec, int dispatches)
          conveniance method to add a filter
 FilterHolder addFilter(String filterClass, String pathSpec, int dispatches)
          convenience method to add a filter
 ServletHolder addServlet(Class<? extends Servlet> servlet, String pathSpec)
          conveniance method to add a servlet.
 void addServlet(ServletHolder servlet, String pathSpec)
          conveniance method to add a servlet.
 ServletHolder addServlet(String className, String pathSpec)
          conveniance method to add a servlet.
 Class<? extends SecurityHandler> getDefaultSecurityHandlerClass()
          Get the defaultSecurityHandlerClass.
 SecurityHandler getSecurityHandler()
           
 ServletHandler getServletHandler()
           
 SessionHandler getSessionHandler()
           
protected  SecurityHandler newSecurityHandler()
           
protected  ServletHandler newServletHandler()
           
protected  SessionHandler newSessionHandler()
           
 void setDefaultSecurityHandlerClass(Class<? extends SecurityHandler> defaultSecurityHandlerClass)
          Set the defaultSecurityHandlerClass.
 void setSecurityHandler(SecurityHandler securityHandler)
           
 void setServletHandler(ServletHandler servletHandler)
           
 void setSessionHandler(SessionHandler sessionHandler)
           
protected  void startContext()
          Finish constructing handlers and link them together.
 
Methods inherited from class org.eclipse.jetty.server.handler.ContextHandler
addEventListener, addLocaleEncoding, checkContext, clearAttributes, complete, doHandle, doScope, doStart, doStop, getAllowNullPathInfo, getAttribute, getAttributeNames, getAttributes, getBaseResource, getClassLoader, getClassPath, getConnectorNames, getContextPath, getCurrentContext, getDisplayName, getErrorHandler, getEventListeners, getHosts, getInitParameter, getInitParameterNames, getInitParams, getLocaleEncoding, getLogger, getMaxFormContentSize, getMimeTypes, getResource, getResourceBase, getResourcePaths, getServletContext, getVirtualHosts, getWelcomeFiles, handle, isAliases, isAvailable, isCompactPath, isProtectedTarget, isShutdown, loadClass, newResource, newResource, removeAttribute, setAliases, setAllowNullPathInfo, setAttribute, setAttributes, setAvailable, setBaseResource, setClassLoader, setCompactPath, setConnectorNames, setContextPath, setDisplayName, setErrorHandler, setEventListeners, setHosts, setInitParams, setLogger, setMaxFormContentSize, setMimeTypes, setResourceBase, setServer, setShutdown, setVirtualHosts, setWelcomeFiles, toString
 
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler
handle, nextHandle, nextScope
 
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
expandChildren, getHandler, getHandlers, setHandler
 
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer
dump, expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
 
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
destroy, dump, getServer
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.jetty.server.Handler
destroy, getServer, handle
 
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

Field Detail

SESSIONS

public static final int SESSIONS
See Also:
Constant Field Values

SECURITY

public static final int SECURITY
See Also:
Constant Field Values

NO_SESSIONS

public static final int NO_SESSIONS
See Also:
Constant Field Values

NO_SECURITY

public static final int NO_SECURITY
See Also:
Constant Field Values

_defaultSecurityHandlerClass

protected Class<? extends SecurityHandler> _defaultSecurityHandlerClass

_sessionHandler

protected SessionHandler _sessionHandler

_securityHandler

protected SecurityHandler _securityHandler

_servletHandler

protected ServletHandler _servletHandler

_options

protected int _options
Constructor Detail

ServletContextHandler

public ServletContextHandler()

ServletContextHandler

public ServletContextHandler(int options)

ServletContextHandler

public ServletContextHandler(HandlerContainer parent,
                             String contextPath)

ServletContextHandler

public ServletContextHandler(HandlerContainer parent,
                             String contextPath,
                             int options)

ServletContextHandler

public ServletContextHandler(HandlerContainer parent,
                             String contextPath,
                             boolean sessions,
                             boolean security)

ServletContextHandler

public ServletContextHandler(HandlerContainer parent,
                             SessionHandler sessionHandler,
                             SecurityHandler securityHandler,
                             ServletHandler servletHandler,
                             ErrorHandler errorHandler)

ServletContextHandler

public ServletContextHandler(HandlerContainer parent,
                             String contextPath,
                             SessionHandler sessionHandler,
                             SecurityHandler securityHandler,
                             ServletHandler servletHandler,
                             ErrorHandler errorHandler)
Method Detail

getDefaultSecurityHandlerClass

public Class<? extends SecurityHandler> getDefaultSecurityHandlerClass()
Get the defaultSecurityHandlerClass.

Returns:
the defaultSecurityHandlerClass

setDefaultSecurityHandlerClass

public void setDefaultSecurityHandlerClass(Class<? extends SecurityHandler> defaultSecurityHandlerClass)
Set the defaultSecurityHandlerClass.

Parameters:
defaultSecurityHandlerClass - the defaultSecurityHandlerClass to set

newSessionHandler

protected SessionHandler newSessionHandler()

newSecurityHandler

protected SecurityHandler newSecurityHandler()

newServletHandler

protected ServletHandler newServletHandler()

startContext

protected void startContext()
                     throws Exception
Finish constructing handlers and link them together.

Overrides:
startContext in class ContextHandler
Throws:
Exception
See Also:
ContextHandler.startContext()

getSecurityHandler

public SecurityHandler getSecurityHandler()
Returns:
Returns the securityHandler.

getServletHandler

public ServletHandler getServletHandler()
Returns:
Returns the servletHandler.

getSessionHandler

public SessionHandler getSessionHandler()
Returns:
Returns the sessionHandler.

addServlet

public ServletHolder addServlet(String className,
                                String pathSpec)
conveniance method to add a servlet.


addServlet

public ServletHolder addServlet(Class<? extends Servlet> servlet,
                                String pathSpec)
conveniance method to add a servlet.


addServlet

public void addServlet(ServletHolder servlet,
                       String pathSpec)
conveniance method to add a servlet.


addFilter

public void addFilter(FilterHolder holder,
                      String pathSpec,
                      int dispatches)
conveniance method to add a filter


addFilter

public FilterHolder addFilter(Class<? extends Filter> filterClass,
                              String pathSpec,
                              int dispatches)
convenience method to add a filter


addFilter

public FilterHolder addFilter(String filterClass,
                              String pathSpec,
                              int dispatches)
convenience method to add a filter


setSessionHandler

public void setSessionHandler(SessionHandler sessionHandler)
Parameters:
sessionHandler - The sessionHandler to set.

setSecurityHandler

public void setSecurityHandler(SecurityHandler securityHandler)
Parameters:
securityHandler - The org.eclipse.jetty.server.handler.SecurityHandler to set on this context.

setServletHandler

public void setServletHandler(ServletHandler servletHandler)
Parameters:
servletHandler - The servletHandler to set.


Copyright © 1995-2009 Mort Bay Consulting. All Rights Reserved.