public class ServletHandler extends AbstractHandler
This handler does not implement the full J2EE features and is intended to
be used when a full web application is not required. Specifically filters
and request wrapping are not supported.
Unless run as part of a Context
or derivative, the initialize()
method must be called manually after start().
WebAppContext
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
__DEFAULT_SERVLET |
static java.lang.String |
__J_S_CONTEXT_TEMPDIR |
static java.lang.String |
__J_S_ERROR_EXCEPTION |
static java.lang.String |
__J_S_ERROR_EXCEPTION_TYPE |
static java.lang.String |
__J_S_ERROR_MESSAGE |
static java.lang.String |
__J_S_ERROR_REQUEST_URI |
static java.lang.String |
__J_S_ERROR_SERVLET_NAME |
static java.lang.String |
__J_S_ERROR_STATUS_CODE |
protected org.mortbay.jetty.servlet.ServletHandler.MruCache[] |
_chainCache |
_string
Constructor and Description |
---|
ServletHandler()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addFilter(FilterHolder filter)
Convenience method to add a preconstructed FilterHolder
|
void |
addFilter(FilterHolder filter,
FilterMapping filterMapping)
convenience method to add a filter and mapping
|
FilterHolder |
addFilter(java.lang.String className,
java.lang.String pathSpec,
int dispatches)
Deprecated.
|
void |
addFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping
|
FilterHolder |
addFilterWithMapping(java.lang.Class filter,
java.lang.String pathSpec,
int dispatches)
conveniance method to add a filter.
|
void |
addFilterWithMapping(FilterHolder holder,
java.lang.String pathSpec,
int dispatches)
conveniance method to add a filter.
|
FilterHolder |
addFilterWithMapping(java.lang.String className,
java.lang.String pathSpec,
int dispatches)
conveniance method to add a filter.
|
void |
addServlet(ServletHolder holder)
Convenience method to add a pre-constructed ServletHolder.
|
ServletHolder |
addServlet(java.lang.String className,
java.lang.String pathSpec)
Deprecated.
|
void |
addServletMapping(ServletMapping mapping)
Convenience method to add a pre-constructed ServletMapping.
|
ServletHolder |
addServletWithMapping(java.lang.Class servlet,
java.lang.String pathSpec)
conveniance method to add a servlet.
|
void |
addServletWithMapping(ServletHolder servlet,
java.lang.String pathSpec)
conveniance method to add a servlet.
|
ServletHolder |
addServletWithMapping(java.lang.String className,
java.lang.String pathSpec)
conveniance method to add a servlet.
|
Filter |
customizeFilter(Filter filter)
Customize a Filter.
|
Filter |
customizeFilterDestroy(Filter filter) |
Servlet |
customizeServlet(Servlet servlet)
Customize a servlet.
|
Servlet |
customizeServletDestroy(Servlet servlet) |
protected void |
doStart() |
protected void |
doStop() |
java.lang.Object |
getContextLog() |
FilterHolder |
getFilter(java.lang.String name) |
FilterMapping[] |
getFilterMappings() |
FilterHolder[] |
getFilters()
Get Filters.
|
PathMap.Entry |
getHolderEntry(java.lang.String pathInContext)
ServletHolder matching path.
|
int |
getMaxFilterChainsCacheSize() |
RequestDispatcher |
getRequestDispatcher(java.lang.String uriInContext) |
ServletHolder |
getServlet(java.lang.String name) |
ServletContext |
getServletContext() |
ServletMapping[] |
getServletMappings() |
ServletHolder[] |
getServlets()
Get Servlets.
|
void |
handle(java.lang.String target,
HttpServletRequest request,
HttpServletResponse response,
int type)
Handle a request.
|
void |
initialize()
Initialize filters and load-on-startup servlets.
|
boolean |
isAvailable() |
boolean |
isFilterChainsCached() |
boolean |
isInitializeAtStart()
Deprecated.
|
boolean |
isStartWithUnavailable() |
boolean |
matchesPath(java.lang.String pathInContext)
Whether there is a ServletHolder that matches this path
|
FilterHolder |
newFilterHolder() |
FilterHolder |
newFilterHolder(java.lang.Class filter) |
ServletHolder |
newServletHolder() |
ServletHolder |
newServletHolder(java.lang.Class servlet) |
protected void |
notFound(HttpServletRequest request,
HttpServletResponse response) |
void |
setFilterChainsCached(boolean filterChainsCached) |
void |
setFilterMappings(FilterMapping[] filterMappings) |
void |
setFilters(FilterHolder[] holders) |
void |
setInitializeAtStart(boolean initializeAtStart)
Deprecated.
|
void |
setMaxFilterChainsCacheSize(int maxFilterChainsCacheSize)
Set the maximum filter chain cache size.
|
void |
setServer(Server server) |
void |
setServletMappings(ServletMapping[] servletMappings) |
void |
setServlets(ServletHolder[] holders)
Set Servlets.
|
void |
setStartWithUnavailable(boolean start) |
protected void |
updateMappings() |
protected void |
updateNameMappings() |
destroy, getServer, toString
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public static final java.lang.String __DEFAULT_SERVLET
public static final java.lang.String __J_S_CONTEXT_TEMPDIR
public static final java.lang.String __J_S_ERROR_EXCEPTION
public static final java.lang.String __J_S_ERROR_EXCEPTION_TYPE
public static final java.lang.String __J_S_ERROR_MESSAGE
public static final java.lang.String __J_S_ERROR_REQUEST_URI
public static final java.lang.String __J_S_ERROR_SERVLET_NAME
public static final java.lang.String __J_S_ERROR_STATUS_CODE
protected transient org.mortbay.jetty.servlet.ServletHandler.MruCache[] _chainCache
public void setServer(Server server)
setServer
in interface Handler
setServer
in class AbstractHandler
protected void doStart() throws java.lang.Exception
doStart
in class AbstractHandler
java.lang.Exception
protected void doStop() throws java.lang.Exception
doStop
in class AbstractHandler
java.lang.Exception
public java.lang.Object getContextLog()
public FilterMapping[] getFilterMappings()
public FilterHolder[] getFilters()
public PathMap.Entry getHolderEntry(java.lang.String pathInContext)
pathInContext
- Path within _context.public boolean matchesPath(java.lang.String pathInContext)
pathInContext
- Path within _context.public RequestDispatcher getRequestDispatcher(java.lang.String uriInContext)
dispatcher
wrapping the resource at uriInContext
,
or null
if the specified uri cannot be dispatched to.public ServletContext getServletContext()
public ServletMapping[] getServletMappings()
public ServletHolder[] getServlets()
public ServletHolder getServlet(java.lang.String name)
public void handle(java.lang.String target, HttpServletRequest request, HttpServletResponse response, int type) throws java.io.IOException, ServletException
Handler
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.type
- The dispatch mode: Handler.REQUEST
, Handler.FORWARD
, Handler.INCLUDE
, Handler.ERROR
java.io.IOException
ServletException
public boolean isInitializeAtStart()
public void setInitializeAtStart(boolean initializeAtStart)
initializeAtStart
- The initializeAtStart to set.public boolean isAvailable()
public void setStartWithUnavailable(boolean start)
start
- True if this handler will start with unavailable servletspublic boolean isStartWithUnavailable()
public void initialize() throws java.lang.Exception
java.lang.Exception
public boolean isFilterChainsCached()
public ServletHolder newServletHolder()
newServletHolder(Class)
public ServletHolder newServletHolder(java.lang.Class servlet)
public ServletHolder addServletWithMapping(java.lang.String className, java.lang.String pathSpec)
public ServletHolder addServletWithMapping(java.lang.Class servlet, java.lang.String pathSpec)
public void addServletWithMapping(ServletHolder servlet, java.lang.String pathSpec)
name
- className
- pathSpec
- public ServletHolder addServlet(java.lang.String className, java.lang.String pathSpec)
className
- pathSpec
- public void addServlet(ServletHolder holder)
holder
- public void addServletMapping(ServletMapping mapping)
mapping
- public FilterHolder newFilterHolder(java.lang.Class filter)
public FilterHolder newFilterHolder()
#newFilterHolder(Class)}
public FilterHolder getFilter(java.lang.String name)
public FilterHolder addFilterWithMapping(java.lang.Class filter, java.lang.String pathSpec, int dispatches)
name
- className
- pathSpec
- dispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(java.lang.String className, java.lang.String pathSpec, int dispatches)
name
- className
- pathSpec
- dispatches
- see FilterMapping.setDispatches(int)
public void addFilterWithMapping(FilterHolder holder, java.lang.String pathSpec, int dispatches)
name
- className
- pathSpec
- dispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilter(java.lang.String className, java.lang.String pathSpec, int dispatches)
className
- pathSpec
- dispatches
- public void addFilter(FilterHolder filter, FilterMapping filterMapping)
filter
- filterMapping
- public void addFilter(FilterHolder filter)
filter
- public void addFilterMapping(FilterMapping mapping)
mapping
- protected void updateNameMappings()
protected void updateMappings()
protected void notFound(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException
java.io.IOException
public void setFilterChainsCached(boolean filterChainsCached)
filterChainsCached
- The filterChainsCached to set.public void setFilterMappings(FilterMapping[] filterMappings)
filterMappings
- The filterMappings to set.public void setFilters(FilterHolder[] holders)
public void setServletMappings(ServletMapping[] servletMappings)
servletMappings
- The servletMappings to set.public void setServlets(ServletHolder[] holders)
holders
- Array of servletsto definepublic int getMaxFilterChainsCacheSize()
public void setMaxFilterChainsCacheSize(int maxFilterChainsCacheSize)
isFilterChainsCached()
is true. If the max cache size
is greater than zero, then the cache is flushed whenever it grows to be this size.maxFilterChainsCacheSize
- the maximum number of entries in a filter chain cache.public Servlet customizeServlet(Servlet servlet) throws java.lang.Exception
servlet
- java.lang.Exception
public Servlet customizeServletDestroy(Servlet servlet) throws java.lang.Exception
java.lang.Exception
public Filter customizeFilter(Filter filter) throws java.lang.Exception
filter
- java.lang.Exception
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.