public class ServletHandler extends ScopedHandler
This handler does not implement the full J2EE features and is intended to
be used directly when a full web application is not required. If a Web application is required,
then this handler should be used as part of a org.eclipse.jetty.webapp.WebAppContext
.
Unless run as part of a ServletContextHandler
or derivative, the initialize()
method must be called manually after start().
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
static String |
__DEFAULT_SERVLET |
protected ConcurrentMap<String,javax.servlet.FilterChain>[] |
_chainCache |
protected Queue<String>[] |
_chainLRU |
_nextScope, _outerScope
_handler
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
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(String className,
String pathSpec,
EnumSet<javax.servlet.DispatcherType> dispatches)
Deprecated.
use
#addFilterWithMapping(Class, String, EnumSet instead |
void |
addFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping
|
FilterHolder |
addFilterWithMapping(Class<? extends javax.servlet.Filter> filter,
String pathSpec,
EnumSet<javax.servlet.DispatcherType> dispatches)
Convenience method to add a filter.
|
FilterHolder |
addFilterWithMapping(Class<? extends javax.servlet.Filter> filter,
String pathSpec,
int dispatches)
Convenience method to add a filter.
|
void |
addFilterWithMapping(FilterHolder holder,
String pathSpec,
EnumSet<javax.servlet.DispatcherType> dispatches)
Convenience method to add a filter.
|
void |
addFilterWithMapping(FilterHolder holder,
String pathSpec,
int dispatches)
Convenience method to add a filter.
|
FilterHolder |
addFilterWithMapping(String className,
String pathSpec,
EnumSet<javax.servlet.DispatcherType> dispatches)
Convenience method to add a filter.
|
FilterHolder |
addFilterWithMapping(String className,
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(Class<? extends javax.servlet.Servlet> servlet,
String pathSpec)
conveniance method to add a servlet.
|
void |
addServletWithMapping(ServletHolder servlet,
String pathSpec)
conveniance method to add a servlet.
|
ServletHolder |
addServletWithMapping(String className,
String pathSpec)
Convenience method to add a servlet.
|
void |
doHandle(String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
void |
doScope(String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected void |
doStart()
Start the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stop the joined lifecycle beans in the reverse order they were added.
|
void |
dump(Appendable out,
String indent) |
Object |
getContextLog() |
FilterHolder |
getFilter(String name) |
FilterMapping[] |
getFilterMappings() |
FilterHolder[] |
getFilters()
Get Filters.
|
PathMap.Entry |
getHolderEntry(String pathInContext)
ServletHolder matching path.
|
int |
getMaxFilterChainsCacheSize() |
ServletHolder |
getServlet(String name) |
javax.servlet.ServletContext |
getServletContext() |
ServletMapping |
getServletMapping(String pattern) |
ServletMapping[] |
getServletMappings() |
ServletHolder[] |
getServlets()
Get Servlets.
|
void |
initialize()
Initialize filters and load-on-startup servlets.
|
protected FilterMapping[] |
insertFilterMapping(FilterMapping mapping,
int pos,
boolean before)
Insert a filtermapping in the list
|
boolean |
isAvailable() |
boolean |
isFilterChainsCached() |
boolean |
isStartWithUnavailable() |
FilterHolder |
newFilterHolder(Holder.Source source) |
ServletHolder |
newServletHolder(Holder.Source source)
see also newServletHolder(Class)
|
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.
|
Set<String> |
setServletSecurity(javax.servlet.ServletRegistration.Dynamic registration,
javax.servlet.ServletSecurityElement servletSecurityElement) |
void |
setStartWithUnavailable(boolean start) |
protected void |
updateMappings() |
protected void |
updateNameMappings() |
handle, never, nextHandle, nextScope
destroy, expandChildren, getHandler, getHandlers, getNestedHandlerByClass, setHandler
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
dumpThis, getServer
addBean, addBean, contains, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public static final String __DEFAULT_SERVLET
protected final ConcurrentMap<String,javax.servlet.FilterChain>[] _chainCache
public void setServer(Server server)
setServer
in interface Handler
setServer
in class HandlerWrapper
protected void doStart() throws Exception
AggregateLifeCycle
doStart
in class ScopedHandler
Exception
HandlerWrapper.doStart()
protected void doStop() throws Exception
AggregateLifeCycle
doStop
in class HandlerWrapper
Exception
AbstractLifeCycle.doStart()
public Object getContextLog()
public FilterMapping[] getFilterMappings()
public FilterHolder[] getFilters()
public PathMap.Entry getHolderEntry(String pathInContext)
pathInContext
- Path within _context.public javax.servlet.ServletContext getServletContext()
public ServletMapping[] getServletMappings()
public ServletMapping getServletMapping(String pattern)
public ServletHolder[] getServlets()
public ServletHolder getServlet(String name)
public void doScope(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
doScope
in class ScopedHandler
IOException
javax.servlet.ServletException
public void doHandle(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
doHandle
in class ScopedHandler
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 Exception
Exception
public boolean isFilterChainsCached()
public ServletHolder newServletHolder(Holder.Source source)
public ServletHolder addServletWithMapping(String className, String pathSpec)
public ServletHolder addServletWithMapping(Class<? extends javax.servlet.Servlet> servlet, String pathSpec)
public void addServletWithMapping(ServletHolder servlet, String pathSpec)
servlet
- servlet holder to addpathSpec
- servlet mappings for the servletHolderpublic void addServlet(ServletHolder holder)
holder
- public void addServletMapping(ServletMapping mapping)
mapping
- public Set<String> setServletSecurity(javax.servlet.ServletRegistration.Dynamic registration, javax.servlet.ServletSecurityElement servletSecurityElement)
public FilterHolder newFilterHolder(Holder.Source source)
#newFilterHolder(Class)
public FilterHolder getFilter(String name)
public FilterHolder addFilterWithMapping(Class<? extends javax.servlet.Filter> filter, String pathSpec, EnumSet<javax.servlet.DispatcherType> dispatches)
filter
- class of filter to createpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(String className, String pathSpec, EnumSet<javax.servlet.DispatcherType> dispatches)
className
- of filterpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public void addFilterWithMapping(FilterHolder holder, String pathSpec, EnumSet<javax.servlet.DispatcherType> dispatches)
holder
- filter holder to addpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(Class<? extends javax.servlet.Filter> filter, String pathSpec, int dispatches)
filter
- class of filter to createpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(String className, String pathSpec, int dispatches)
className
- of filterpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public void addFilterWithMapping(FilterHolder holder, String pathSpec, int dispatches)
holder
- filter holder to addpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilter(String className, String pathSpec, EnumSet<javax.servlet.DispatcherType> dispatches)
#addFilterWithMapping(Class, String, EnumSet)
insteadclassName
- 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 FilterMapping[] insertFilterMapping(FilterMapping mapping, int pos, boolean before)
mapping
- the FilterMapping to addpos
- the position in the existing arry at which to add itbefore
- if true, insert before pos, if false insert after itprotected void updateNameMappings()
protected void updateMappings()
protected void notFound(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
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 void dump(Appendable out, String indent) throws IOException
dump
in interface Dumpable
dump
in class AbstractHandlerContainer
IOException
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.