org.mortbay.jetty.servlet
Class WebApplicationHandler

java.lang.Object
  extended by org.mortbay.util.Container
      extended by org.mortbay.jetty.servlet.ServletHandler
          extended by org.mortbay.jetty.servlet.WebApplicationHandler
All Implemented Interfaces:
java.io.Serializable, HttpHandler, EventProvider, LifeCycle

public class WebApplicationHandler
extends ServletHandler

WebApp HttpHandler. This handler extends the ServletHandler with security, filter and resource capabilities to provide full J2EE web container support.

Since:
Jetty 4.1
Version:
$Id: WebApplicationHandler.java,v 1.62 2006/01/04 13:55:31 gregwilkins Exp $
Author:
Greg Wilkins
See Also:
WebApplicationContext, Serialized Form

Field Summary
protected  java.util.HashMap[] _chainCache
           
protected  java.lang.Object _contextAttributeListeners
           
protected  java.util.HashMap[] _namedChainCache
           
protected  java.lang.Object _requestAttributeListeners
           
protected  java.lang.Object _requestListeners
           
protected  java.lang.Object _sessionListeners
           
protected  JSR154Filter jsr154Filter
           
protected  FilterHolder jsr154FilterHolder
           
 
Fields inherited from class org.mortbay.jetty.servlet.ServletHandler
__DEFAULT_SERVLET, __J_S_CONTEXT_TEMPDIR, __J_S_ERROR_EXCEPTION, __J_S_ERROR_EXCEPTION_TYPE, __J_S_ERROR_MESSAGE, __J_S_ERROR_REQUEST_URI, __J_S_ERROR_SERVLET_NAME, __J_S_ERROR_STATUS_CODE, _attributes, _context, _contextLog, _formErrorPage, _formLoginPage, _httpContext, _loader, _nameMap, _servletMap, _sessionManager
 
Constructor Summary
WebApplicationHandler()
           
 
Method Summary
protected  void addComponent(java.lang.Object o)
           
 void addEventListener(java.util.EventListener listener)
          Add a server event listener.
 void addFilterHolder(FilterHolder holder)
           
 FilterHolder addFilterPathMapping(java.lang.String pathSpec, java.lang.String filterName, int dispatches)
          Add a mapping from a pathSpec to a Filter.
 FilterHolder addFilterServletMapping(java.lang.String servletName, java.lang.String filterName, int dispatches)
          Add a servlet filter mapping
 FilterHolder defineFilter(java.lang.String name, java.lang.String className)
           
 void destroy()
          Destroy a stopped server.
protected  void dispatch(java.lang.String pathInContext, HttpServletRequest request, HttpServletResponse response, ServletHolder servletHolder, int type)
          Dispatch to a servletHolder.
protected  void doStart()
          Do start operations.
protected  void doStop()
          Do stop operations.
 java.lang.String getErrorPage(int status, ServletHttpRequest request)
           
 FilterHolder getFilter(java.lang.String name)
           
 java.util.List getFilters()
           
 JSR154Filter getJsr154Filter()
           
 void initializeServlets()
          Initialize load-on-startup servlets.
 boolean isAcceptRanges()
           
 boolean isFilterChainsCached()
           
static void main(java.lang.String[] arg)
           
protected  FilterHolder newFilterHolder(java.lang.String name, java.lang.String className)
           
protected  void removeComponent(java.lang.Object o)
           
 void removeContextAttribute(java.lang.String name)
           
 void removeEventListener(java.util.EventListener listener)
           
 void setAcceptRanges(boolean ar)
          Set if the handler accepts range requests.
 void setContextAttribute(java.lang.String name, java.lang.Object value)
           
 void setFilterChainsCached(boolean filterChainsCached)
          Cache filter chains.
 void setSessionManager(SessionManager sm)
           
 
Methods inherited from class org.mortbay.jetty.servlet.ServletHandler
addServlet, addServlet, addServlet, addServletHolder, finalize, formAuthInit, getClassLoader, getContextAttribute, getContextAttributeNames, getHolderEntry, getHttpContext, getHttpSession, getName, getNamedDispatcher, getRealPath, getRequestDispatcher, getResource, getResourceAsStream, getResourcePaths, getServletContext, getServletHolder, getServletMap, getServlets, getSessionManager, handle, handleOptions, handleTrace, handleTrace, initialize, isAutoInitializeServlets, isUsingCookies, mapPathToServlet, newHttpSession, newServletHolder, newServletHolder, notFound, setAutoInitializeServlets, setDynamicInitParams, setDynamicServletPathSpec, setName, setServeDynamicSystemServlets, setSessionInactiveInterval, setUsingCookies
 
Methods inherited from class org.mortbay.util.Container
getComponents, isFailed, isStarted, isStarting, isStopping, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mortbay.util.LifeCycle
isStarted, start, stop
 

Field Detail

_requestListeners

protected transient java.lang.Object _requestListeners

_requestAttributeListeners

protected transient java.lang.Object _requestAttributeListeners

_sessionListeners

protected transient java.lang.Object _sessionListeners

_contextAttributeListeners

protected transient java.lang.Object _contextAttributeListeners

jsr154FilterHolder

protected transient FilterHolder jsr154FilterHolder

jsr154Filter

protected transient JSR154Filter jsr154Filter

_chainCache

protected transient java.util.HashMap[] _chainCache

_namedChainCache

protected transient java.util.HashMap[] _namedChainCache
Constructor Detail

WebApplicationHandler

public WebApplicationHandler()
Method Detail

isAcceptRanges

public boolean isAcceptRanges()

setAcceptRanges

public void setAcceptRanges(boolean ar)
Set if the handler accepts range requests. Default is false;

Parameters:
ar - True if the handler should accept ranges

getJsr154Filter

public JSR154Filter getJsr154Filter()
Returns:
Returns the jsr154Filter.

defineFilter

public FilterHolder defineFilter(java.lang.String name,
                                 java.lang.String className)

newFilterHolder

protected FilterHolder newFilterHolder(java.lang.String name,
                                       java.lang.String className)

addFilterHolder

public void addFilterHolder(FilterHolder holder)

getFilter

public FilterHolder getFilter(java.lang.String name)

addFilterPathMapping

public FilterHolder addFilterPathMapping(java.lang.String pathSpec,
                                         java.lang.String filterName,
                                         int dispatches)
Add a mapping from a pathSpec to a Filter.

Parameters:
pathSpec - The path specification
filterName - The name of the filter (must already be added or defined)
dispatches - An integer formed by the logical OR of FilterHolder.__REQUEST, FilterHolder.__FORWARD,FilterHolder.__INCLUDE and/or FilterHolder.__ERROR.
Returns:
The holder of the filter instance.

addFilterServletMapping

public FilterHolder addFilterServletMapping(java.lang.String servletName,
                                            java.lang.String filterName,
                                            int dispatches)
Add a servlet filter mapping

Parameters:
servletName - The name of the servlet to be filtered.
filterName - The name of the filter.
dispatches - An integer formed by the logical OR of FilterHolder.__REQUEST, FilterHolder.__FORWARD,FilterHolder.__INCLUDE and/or FilterHolder.__ERROR.
Returns:
The holder of the filter instance.

getFilters

public java.util.List getFilters()

addEventListener

public void addEventListener(java.util.EventListener listener)
                      throws java.lang.IllegalArgumentException
Description copied from class: Container
Add a server event listener.

Specified by:
addEventListener in interface EventProvider
Overrides:
addEventListener in class Container
Parameters:
listener - ComponentEventListener or LifeCycleEventListener
Throws:
java.lang.IllegalArgumentException - If the EventListener type is not supported.

removeEventListener

public void removeEventListener(java.util.EventListener listener)
Specified by:
removeEventListener in interface EventProvider
Overrides:
removeEventListener in class Container

setSessionManager

public void setSessionManager(SessionManager sm)
Overrides:
setSessionManager in class ServletHandler

doStart

protected void doStart()
                throws java.lang.Exception
Description copied from class: Container
Do start operations. This abstract method is called by start to perform the actual start operations.

Overrides:
doStart in class ServletHandler
Throws:
java.lang.Exception

initializeServlets

public void initializeServlets()
                        throws java.lang.Exception
Description copied from class: ServletHandler
Initialize load-on-startup servlets. Called automatically from start if autoInitializeServlet is true.

Overrides:
initializeServlets in class ServletHandler
Throws:
java.lang.Exception

doStop

protected void doStop()
               throws java.lang.Exception
Description copied from class: Container
Do stop operations. This abstract method is called by stop to perform the actual stop operations.

Overrides:
doStop in class ServletHandler
Throws:
java.lang.Exception

getErrorPage

public java.lang.String getErrorPage(int status,
                                     ServletHttpRequest request)
Overrides:
getErrorPage in class ServletHandler

dispatch

protected void dispatch(java.lang.String pathInContext,
                        HttpServletRequest request,
                        HttpServletResponse response,
                        ServletHolder servletHolder,
                        int type)
                 throws ServletException,
                        UnavailableException,
                        java.io.IOException
Description copied from class: ServletHandler
Dispatch to a servletHolder. This method may be specialized to insert extra handling in the dispatch of a request to a specific servlet. This is used by WebApplicatonHandler to implement dispatched filters. The default implementation simply calls ServletHolder.handle(request,response)

Overrides:
dispatch in class ServletHandler
Parameters:
pathInContext - The path used to select the servlet holder.
type - the type of dispatch as defined in the Dispatcher class.
Throws:
ServletException
UnavailableException
java.io.IOException

setContextAttribute

public void setContextAttribute(java.lang.String name,
                                java.lang.Object value)
Overrides:
setContextAttribute in class ServletHandler

removeContextAttribute

public void removeContextAttribute(java.lang.String name)
Overrides:
removeContextAttribute in class ServletHandler

isFilterChainsCached

public boolean isFilterChainsCached()
Returns:
Returns the filterChainsCached.

setFilterChainsCached

public void setFilterChainsCached(boolean filterChainsCached)
Cache filter chains. If true, filter chains are cached by the URI path within the context. Caching should not be used if the webapp encodes information in URLs.

Parameters:
filterChainsCached - The filterChainsCached to set.

addComponent

protected void addComponent(java.lang.Object o)
Overrides:
addComponent in class Container
See Also:
Container.addComponent(java.lang.Object)

removeComponent

protected void removeComponent(java.lang.Object o)
Overrides:
removeComponent in class Container
See Also:
Container.removeComponent(java.lang.Object)

destroy

public void destroy()
Description copied from class: Container
Destroy a stopped server. Remove all components and send notifications to all event listeners. The HttpServer must be stopped before it can be destroyed.

Overrides:
destroy in class ServletHandler

main

public static void main(java.lang.String[] arg)


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.