|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.jetty.util.component.AbstractLifeCycle org.eclipse.jetty.server.handler.AbstractHandler org.eclipse.jetty.server.handler.AbstractHandlerContainer org.eclipse.jetty.server.handler.HandlerWrapper org.eclipse.jetty.server.handler.ScopedHandler org.eclipse.jetty.servlet.ServletHandler
public class ServletHandler
Servlet HttpHandler. This handler maps requests to servlets that implement the javax.servlet.http.HttpServlet API.
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 ServletContextHandler
or derivative, the initialize()
method must be called manually after start().
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
AbstractLifeCycle.AbstractLifeCycleListener |
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary | |
---|---|
static java.lang.String |
__DEFAULT_SERVLET
|
protected java.util.concurrent.ConcurrentMap<java.lang.String,javax.servlet.FilterChain>[] |
_chainCache
|
protected java.util.Queue<java.lang.String>[] |
_chainLRU
|
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 |
Constructor Summary | |
---|---|
ServletHandler()
Constructor. |
Method Summary | |
---|---|
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,
java.util.EnumSet<DispatcherType> dispatches)
Deprecated. use addFilterWithMapping(Class, String, int) instead |
void |
addFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping |
FilterHolder |
addFilterWithMapping(java.lang.Class<? extends javax.servlet.Filter> filter,
java.lang.String pathSpec,
java.util.EnumSet<DispatcherType> dispatches)
Convenience method to add a filter. |
FilterHolder |
addFilterWithMapping(java.lang.Class<? extends javax.servlet.Filter> filter,
java.lang.String pathSpec,
int dispatches)
Convenience method to add a filter. |
void |
addFilterWithMapping(FilterHolder holder,
java.lang.String pathSpec,
java.util.EnumSet<DispatcherType> dispatches)
Convenience method to add a filter. |
void |
addFilterWithMapping(FilterHolder holder,
java.lang.String pathSpec,
int dispatches)
Convenience method to add a filter. |
FilterHolder |
addFilterWithMapping(java.lang.String className,
java.lang.String pathSpec,
java.util.EnumSet<DispatcherType> dispatches)
Convenience method to add a filter. |
FilterHolder |
addFilterWithMapping(java.lang.String className,
java.lang.String pathSpec,
int dispatches)
Convenience method to add a filter. |
void |
addServlet(ServletHolder holder)
Convenience method to add a pre-constructed ServletHolder. |
void |
addServletMapping(ServletMapping mapping)
Convenience method to add a pre-constructed ServletMapping. |
ServletHolder |
addServletWithMapping(java.lang.Class<? extends javax.servlet.Servlet> 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. |
void |
doHandle(java.lang.String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
doScope(java.lang.String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected void |
doStart()
|
protected void |
doStop()
|
protected void |
dump(java.lang.Appendable out,
java.lang.String indent)
|
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()
|
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String uriInContext)
|
ServletHolder |
getServlet(java.lang.String name)
|
javax.servlet.ServletContext |
getServletContext()
|
ServletMapping |
getServletMapping(java.lang.String pattern)
|
ServletMapping[] |
getServletMappings()
|
ServletHolder[] |
getServlets()
Get Servlets. |
void |
initialize()
Initialize filters and load-on-startup servlets. |
boolean |
isAvailable()
|
boolean |
isFilterChainsCached()
|
boolean |
isStartWithUnavailable()
|
FilterHolder |
newFilterHolder()
|
FilterHolder |
newFilterHolder(java.lang.Class<? extends javax.servlet.Filter> filter)
|
ServletHolder |
newServletHolder()
see also newServletHolder(Class) |
ServletHolder |
newServletHolder(java.lang.Class<? extends javax.servlet.Servlet> servlet)
|
protected void |
notFound(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
prependFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping |
void |
setFilterChainsCached(boolean filterChainsCached)
|
void |
setFilterMappings(FilterMapping[] filterMappings)
|
void |
setFilters(FilterHolder[] holders)
|
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()
|
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler |
---|
handle, never, nextHandle, nextScope |
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper |
---|
expandChildren, getHandler, getHandlers, getNestedHandlerByClass, setHandler |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer |
---|
dumpHandlers, expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler |
---|
destroy, dump, dump, getServer, toString |
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.util.component.LifeCycle |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Field Detail |
---|
public static final java.lang.String __DEFAULT_SERVLET
protected final java.util.concurrent.ConcurrentMap<java.lang.String,javax.servlet.FilterChain>[] _chainCache
protected final java.util.Queue<java.lang.String>[] _chainLRU
Constructor Detail |
---|
public ServletHandler()
Method Detail |
---|
public void setServer(Server server)
setServer
in interface Handler
setServer
in class HandlerWrapper
protected void doStart() throws java.lang.Exception
doStart
in class ScopedHandler
java.lang.Exception
HandlerWrapper.doStart()
protected void doStop() throws java.lang.Exception
doStop
in class HandlerWrapper
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 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String uriInContext)
uriInContext
- uri to get dispatcher for
dispatcher
wrapping the resource at uriInContext
,
or null
if the specified uri cannot be dispatched to.public javax.servlet.ServletContext getServletContext()
public ServletMapping[] getServletMappings()
public ServletMapping getServletMapping(java.lang.String pattern)
public ServletHolder[] getServlets()
public ServletHolder getServlet(java.lang.String name)
public void doScope(java.lang.String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doScope
in class ScopedHandler
java.io.IOException
javax.servlet.ServletException
public void doHandle(java.lang.String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doHandle
in class ScopedHandler
java.io.IOException
javax.servlet.ServletException
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()
public ServletHolder newServletHolder(java.lang.Class<? extends javax.servlet.Servlet> servlet)
public ServletHolder addServletWithMapping(java.lang.String className, java.lang.String pathSpec)
public ServletHolder addServletWithMapping(java.lang.Class<? extends javax.servlet.Servlet> servlet, java.lang.String pathSpec)
public void addServletWithMapping(ServletHolder servlet, java.lang.String pathSpec)
servlet
- servlet holder to addpathSpec
- servlet mappings for the servletHolderpublic void addServlet(ServletHolder holder)
holder
- public void addServletMapping(ServletMapping mapping)
mapping
- public FilterHolder newFilterHolder(java.lang.Class<? extends javax.servlet.Filter> filter)
public FilterHolder newFilterHolder()
newFilterHolder(Class)
public FilterHolder getFilter(java.lang.String name)
public FilterHolder addFilterWithMapping(java.lang.Class<? extends javax.servlet.Filter> filter, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
filter
- class of filter to createpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(java.lang.String className, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
className
- of filterpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public void addFilterWithMapping(FilterHolder holder, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
holder
- filter holder to addpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(java.lang.Class<? extends javax.servlet.Filter> filter, java.lang.String pathSpec, int dispatches)
filter
- class of filter to createpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(java.lang.String className, java.lang.String pathSpec, int dispatches)
className
- of filterpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public void addFilterWithMapping(FilterHolder holder, java.lang.String pathSpec, int dispatches)
holder
- filter holder to addpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilter(java.lang.String className, java.lang.String pathSpec, java.util.EnumSet<DispatcherType> dispatches)
addFilterWithMapping(Class, String, int)
instead
className
- pathSpec
- dispatches
-
public void addFilter(FilterHolder filter, FilterMapping filterMapping)
filter
- filterMapping
- public void addFilter(FilterHolder filter)
filter
- public void addFilterMapping(FilterMapping mapping)
mapping
- public void prependFilterMapping(FilterMapping mapping)
mapping
- protected void updateNameMappings()
protected void updateMappings()
protected void notFound(javax.servlet.http.HttpServletRequest request, javax.servlet.http.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.protected void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
dump
in class AbstractHandlerContainer
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |