|
||||||||||
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().
WebAppContext
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary | |
---|---|
static String |
__DEFAULT_SERVLET
|
protected ConcurrentHashMap[] |
_chainCache
|
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(String className,
String pathSpec,
int dispatches)
Deprecated. |
void |
addFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping |
FilterHolder |
addFilterWithMapping(Class<? extends Filter> filter,
String pathSpec,
int dispatches)
conveniance method to add a filter. |
void |
addFilterWithMapping(FilterHolder holder,
String pathSpec,
int dispatches)
conveniance method to add a filter. |
FilterHolder |
addFilterWithMapping(String className,
String pathSpec,
int dispatches)
conveniance method to add a filter. |
void |
addServlet(ServletHolder holder)
Convenience method to add a pre-constructed ServletHolder. |
ServletHolder |
addServlet(String className,
String pathSpec)
Deprecated. |
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)
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)
|
void |
doHandle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
|
void |
doScope(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
|
protected void |
doStart()
|
protected void |
doStop()
|
protected void |
dump(StringBuilder b,
String indent)
|
Object |
getContextLog()
|
FilterHolder |
getFilter(String name)
|
FilterMapping[] |
getFilterMappings()
|
FilterHolder[] |
getFilters()
Get Filters. |
PathMap.Entry |
getHolderEntry(String pathInContext)
ServletHolder matching path. |
int |
getMaxFilterChainsCacheSize()
|
RequestDispatcher |
getRequestDispatcher(String uriInContext)
|
ServletHolder |
getServlet(String name)
|
ServletContext |
getServletContext()
|
ServletMapping[] |
getServletMappings()
|
ServletHolder[] |
getServlets()
Get Servlets. |
void |
initialize()
Initialize filters and load-on-startup servlets. |
boolean |
isAvailable()
|
boolean |
isFilterChainsCached()
|
boolean |
isInitializeAtStart()
Deprecated. |
boolean |
isStartWithUnavailable()
|
boolean |
matchesPath(String pathInContext)
Whether there is a ServletHolder that matches this path |
FilterHolder |
newFilterHolder()
|
FilterHolder |
newFilterHolder(Class<? extends Filter> filter)
|
ServletHolder |
newServletHolder()
see also newServletHolder(Class) |
ServletHolder |
newServletHolder(Class servlet)
|
protected void |
notFound(HttpServletRequest request,
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 |
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()
|
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler |
---|
handle, nextHandle, nextScope |
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper |
---|
expandChildren, getHandler, getHandlers, setHandler |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer |
---|
expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass |
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler |
---|
destroy, 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 String __DEFAULT_SERVLET
protected transient ConcurrentHashMap[] _chainCache
Constructor Detail |
---|
public ServletHandler()
Method Detail |
---|
public void setServer(Server server)
setServer
in interface Handler
setServer
in class HandlerWrapper
protected void doStart() throws Exception
doStart
in class ScopedHandler
Exception
HandlerWrapper.doStart()
protected void doStop() throws Exception
doStop
in class HandlerWrapper
Exception
public Object getContextLog()
public FilterMapping[] getFilterMappings()
public FilterHolder[] getFilters()
public PathMap.Entry getHolderEntry(String pathInContext)
pathInContext
- Path within _context.
public boolean matchesPath(String pathInContext)
pathInContext
- Path within _context.
public RequestDispatcher getRequestDispatcher(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 ServletContext getServletContext()
public ServletMapping[] getServletMappings()
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
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 Exception
Exception
public boolean isFilterChainsCached()
public ServletHolder newServletHolder()
public ServletHolder newServletHolder(Class servlet)
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 ServletHolder addServlet(String className, String pathSpec)
className
- pathSpec
-
public void addServlet(ServletHolder holder)
holder
- public void addServletMapping(ServletMapping mapping)
mapping
- public FilterHolder newFilterHolder(Class<? extends Filter> filter)
public FilterHolder newFilterHolder()
#newFilterHolder(Class)}
public FilterHolder getFilter(String name)
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, 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
- public void prependFilterMapping(FilterMapping mapping)
mapping
- protected void updateNameMappings()
protected void updateMappings()
protected void notFound(HttpServletRequest request, 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 Servlet customizeServlet(Servlet servlet) throws Exception
servlet
-
Exception
public Servlet customizeServletDestroy(Servlet servlet) throws Exception
Exception
public Filter customizeFilter(Filter filter) throws Exception
filter
-
Exception
public Filter customizeFilterDestroy(Filter filter) throws Exception
Exception
protected void dump(StringBuilder b, String indent)
dump
in class AbstractHandlerContainer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |