@ManagedObject(value="Servlet Handler") public class ServletHandler extends ScopedHandler
Modifier and Type | Class and Description |
---|---|
static class |
ServletHandler.Default404Servlet |
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Container.InheritedListener, Container.Listener
Modifier and Type | Field and Description |
---|---|
static String |
__DEFAULT_SERVLET |
protected ConcurrentMap<String,FilterChain>[] |
_chainCache |
protected Queue<String>[] |
_chainLRU |
_nextScope, _outerScope
_handler
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<DispatcherType> dispatches)
Deprecated.
use
addFilterWithMapping(Class, String, EnumSet) instead |
void |
addFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping
|
FilterHolder |
addFilterWithMapping(Class<? extends Filter> filter,
String pathSpec,
EnumSet<DispatcherType> dispatches)
Convenience method to add a filter.
|
FilterHolder |
addFilterWithMapping(Class<? extends Filter> filter,
String pathSpec,
int dispatches)
Convenience method to add a filter.
|
void |
addFilterWithMapping(FilterHolder holder,
String pathSpec,
EnumSet<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<DispatcherType> dispatches)
Convenience method to add a filter.
|
FilterHolder |
addFilterWithMapping(String className,
String pathSpec,
int dispatches)
Convenience method to add a filter.
|
void |
addListener(ListenerHolder listener)
Add a holder for a listener
|
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 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,
HttpServletRequest request,
HttpServletResponse response) |
void |
doScope(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) |
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
Object |
getContextLog() |
FilterHolder |
getFilter(String name) |
protected FilterChain |
getFilterChain(Request baseRequest,
String pathInContext,
ServletHolder servletHolder) |
FilterMapping[] |
getFilterMappings() |
FilterHolder[] |
getFilters()
Get Filters.
|
PathMap.MappedEntry<ServletHolder> |
getHolderEntry(String pathInContext)
ServletHolder matching path.
|
protected IdentityService |
getIdentityService() |
ListenerHolder[] |
getListeners() |
int |
getMaxFilterChainsCacheSize() |
ServletHolder |
getServlet(String name) |
ServletContext |
getServletContext() |
ServletMapping |
getServletMapping(String pathSpec)
Get the ServletMapping matching the path
|
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
|
protected void |
invalidateChainsCache() |
boolean |
isAvailable() |
boolean |
isEnsureDefaultServlet() |
boolean |
isFilterChainsCached() |
boolean |
isStartWithUnavailable() |
FilterHolder |
newFilterHolder(BaseHolder.Source source) |
ListenerHolder |
newListenerHolder(BaseHolder.Source source) |
ServletHolder |
newServletHolder(BaseHolder.Source source)
see also newServletHolder(Class)
|
protected void |
notFound(Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) |
void |
prependFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping
|
void |
setEnsureDefaultServlet(boolean ensureDefaultServlet) |
void |
setFilterChainsCached(boolean filterChainsCached) |
void |
setFilterMappings(FilterMapping[] filterMappings) |
void |
setFilters(FilterHolder[] holders) |
void |
setListeners(ListenerHolder[] listeners) |
void |
setMaxFilterChainsCacheSize(int maxFilterChainsCacheSize)
Set the maximum filter chain cache size.
|
void |
setServletMappings(ServletMapping[] servletMappings) |
void |
setServlets(ServletHolder[] holders)
Set Servlets.
|
Set<String> |
setServletSecurity(ServletRegistration.Dynamic registration,
ServletSecurityElement servletSecurityElement) |
void |
setStartWithUnavailable(boolean start) |
protected void |
start(LifeCycle l)
Starts the given lifecycle.
|
protected void |
updateMappings() |
protected void |
updateNameMappings() |
handle, never, nextHandle, nextScope
destroy, expandChildren, getHandler, getHandlers, setHandler, setServer
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
dumpThis, getServer
addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, stop, unmanage, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, 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,FilterChain>[] _chainCache
protected void doStart() throws Exception
ContainerLifeCycle
doStart
in class ScopedHandler
Exception
AbstractHandler.doStart()
public boolean isEnsureDefaultServlet()
ServletHandler.Default404Servlet
if no other
default servlet is configured.public void setEnsureDefaultServlet(boolean ensureDefaultServlet)
ensureDefaultServlet
- true if ServletHandler always has a default servlet, using ServletHandler.Default404Servlet
if no other
default servlet is configured.protected void start(LifeCycle l) throws Exception
ContainerLifeCycle
start
in class ContainerLifeCycle
Exception
protected void doStop() throws Exception
ContainerLifeCycle
doStop
in class AbstractHandler
Exception
protected IdentityService getIdentityService()
public Object getContextLog()
@ManagedAttribute(value="filters", readonly=true) public FilterMapping[] getFilterMappings()
@ManagedAttribute(value="filters", readonly=true) public FilterHolder[] getFilters()
public PathMap.MappedEntry<ServletHolder> getHolderEntry(String pathInContext)
pathInContext
- Path within _context.public ServletContext getServletContext()
@ManagedAttribute(value="mappings of servlets", readonly=true) public ServletMapping[] getServletMappings()
public ServletMapping getServletMapping(String pathSpec)
pathSpec
- @ManagedAttribute(value="servlets", readonly=true) public ServletHolder[] getServlets()
public ServletHolder getServlet(String name)
public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
doScope
in class ScopedHandler
IOException
ServletException
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
doHandle
in class ScopedHandler
IOException
ServletException
protected FilterChain getFilterChain(Request baseRequest, String pathInContext, ServletHolder servletHolder)
protected void invalidateChainsCache()
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 void addListener(ListenerHolder listener)
filter
- public ListenerHolder[] getListeners()
public void setListeners(ListenerHolder[] listeners)
public ListenerHolder newListenerHolder(BaseHolder.Source source)
public ServletHolder newServletHolder(BaseHolder.Source source)
public ServletHolder addServletWithMapping(String className, String pathSpec)
public ServletHolder addServletWithMapping(Class<? extends 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(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement)
public FilterHolder newFilterHolder(BaseHolder.Source source)
public FilterHolder getFilter(String name)
public FilterHolder addFilterWithMapping(Class<? extends Filter> filter, String pathSpec, EnumSet<DispatcherType> dispatches)
filter
- class of filter to createpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(String className, String pathSpec, EnumSet<DispatcherType> dispatches)
className
- of filterpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public void addFilterWithMapping(FilterHolder holder, String pathSpec, EnumSet<DispatcherType> dispatches)
holder
- filter holder to addpathSpec
- filter mappings for filterdispatches
- see FilterMapping.setDispatches(int)
public FilterHolder addFilterWithMapping(Class<? extends 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<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(Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
IOException
ServletException
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 servlets to 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.Copyright © 1995-2015 Webtide. All Rights Reserved.