org.eclipse.jetty.servlet
类 ServletHandler

java.lang.Object
  继承者 org.eclipse.jetty.util.component.AbstractLifeCycle
      继承者 org.eclipse.jetty.util.component.AggregateLifeCycle
          继承者 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
所有已实现的接口:
Handler, HandlerContainer, Destroyable, Dumpable, LifeCycle
直接已知子类:
ServletHandler

public class ServletHandler
extends ScopedHandler

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 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().


嵌套类摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的嵌套类/接口
AbstractLifeCycle.AbstractLifeCycleListener
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的嵌套类/接口
LifeCycle.Listener
 
字段摘要
static String __DEFAULT_SERVLET
           
protected  ConcurrentMap<String,FilterChain>[] _chainCache
           
protected  Queue<String>[] _chainLRU
           
 
从类 org.eclipse.jetty.server.handler.ScopedHandler 继承的字段
_nextScope, _outerScope
 
从类 org.eclipse.jetty.server.handler.HandlerWrapper 继承的字段
_handler
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的字段
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
构造方法摘要
ServletHandler()
          Constructor.
 
方法摘要
 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)
          已过时。 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 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()
          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)
           
 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(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 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(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement)
           
 void setStartWithUnavailable(boolean start)
           
protected  void updateMappings()
           
protected  void updateNameMappings()
           
 
从类 org.eclipse.jetty.server.handler.ScopedHandler 继承的方法
handle, never, nextHandle, nextScope
 
从类 org.eclipse.jetty.server.handler.HandlerWrapper 继承的方法
destroy, expandChildren, getHandler, getHandlers, getNestedHandlerByClass, setHandler
 
从类 org.eclipse.jetty.server.handler.AbstractHandlerContainer 继承的方法
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
 
从类 org.eclipse.jetty.server.handler.AbstractHandler 继承的方法
dumpThis, getServer
 
从类 org.eclipse.jetty.util.component.AggregateLifeCycle 继承的方法
addBean, addBean, contains, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的方法
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的方法
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

字段详细信息

__DEFAULT_SERVLET

public static final String __DEFAULT_SERVLET
另请参见:
常量字段值

_chainCache

protected final ConcurrentMap<String,FilterChain>[] _chainCache

_chainLRU

protected final Queue<String>[] _chainLRU
构造方法详细信息

ServletHandler

public ServletHandler()
Constructor.

方法详细信息

setServer

public void setServer(Server server)
指定者:
接口 Handler 中的 setServer
覆盖:
HandlerWrapper 中的 setServer

doStart

protected void doStart()
                throws Exception
从类 AggregateLifeCycle 复制的描述
Start the managed lifecycle beans in the order they were added.

覆盖:
ScopedHandler 中的 doStart
抛出:
Exception
另请参见:
HandlerWrapper.doStart()

doStop

protected void doStop()
               throws Exception
从类 AggregateLifeCycle 复制的描述
Stop the joined lifecycle beans in the reverse order they were added.

覆盖:
HandlerWrapper 中的 doStop
抛出:
Exception
另请参见:
AbstractLifeCycle.doStart()

getContextLog

public Object getContextLog()
返回:
Returns the contextLog.

getFilterMappings

public FilterMapping[] getFilterMappings()
返回:
Returns the filterMappings.

getFilters

public FilterHolder[] getFilters()
Get Filters.

返回:
Array of defined servlets

getHolderEntry

public PathMap.Entry getHolderEntry(String pathInContext)
ServletHolder matching path.

参数:
pathInContext - Path within _context.
返回:
PathMap Entries pathspec to ServletHolder

getServletContext

public ServletContext getServletContext()

getServletMappings

public ServletMapping[] getServletMappings()
返回:
Returns the servletMappings.

getServletMapping

public ServletMapping getServletMapping(String pattern)
返回:
Returns the servletMappings.

getServlets

public ServletHolder[] getServlets()
Get Servlets.

返回:
Array of defined servlets

getServlet

public ServletHolder getServlet(String name)

doScope

public void doScope(String target,
                    Request baseRequest,
                    HttpServletRequest request,
                    HttpServletResponse response)
             throws IOException,
                    ServletException
指定者:
ScopedHandler 中的 doScope
抛出:
IOException
ServletException

doHandle

public void doHandle(String target,
                     Request baseRequest,
                     HttpServletRequest request,
                     HttpServletResponse response)
              throws IOException,
                     ServletException
指定者:
ScopedHandler 中的 doHandle
抛出:
IOException
ServletException

isAvailable

public boolean isAvailable()
返回:
true if the handler is started and there are no unavailable servlets

setStartWithUnavailable

public void setStartWithUnavailable(boolean start)
参数:
start - True if this handler will start with unavailable servlets

isStartWithUnavailable

public boolean isStartWithUnavailable()
返回:
True if this handler will start with unavailable servlets

initialize

public void initialize()
                throws Exception
Initialize filters and load-on-startup servlets. Called automatically from start if autoInitializeServlet is true.

抛出:
Exception

isFilterChainsCached

public boolean isFilterChainsCached()
返回:
Returns the filterChainsCached.

newServletHolder

public ServletHolder newServletHolder(Holder.Source source)
see also newServletHolder(Class)


addServletWithMapping

public ServletHolder addServletWithMapping(String className,
                                           String pathSpec)
Convenience method to add a servlet.

返回:
The servlet holder.

addServletWithMapping

public ServletHolder addServletWithMapping(Class<? extends Servlet> servlet,
                                           String pathSpec)
conveniance method to add a servlet.

返回:
The servlet holder.

addServletWithMapping

public void addServletWithMapping(ServletHolder servlet,
                                  String pathSpec)
conveniance method to add a servlet.

参数:
servlet - servlet holder to add
pathSpec - servlet mappings for the servletHolder

addServlet

public void addServlet(ServletHolder holder)
Convenience method to add a pre-constructed ServletHolder.

参数:
holder -

addServletMapping

public void addServletMapping(ServletMapping mapping)
Convenience method to add a pre-constructed ServletMapping.

参数:
mapping -

setServletSecurity

public Set<String> setServletSecurity(ServletRegistration.Dynamic registration,
                                      ServletSecurityElement servletSecurityElement)

newFilterHolder

public FilterHolder newFilterHolder(Holder.Source source)
另请参见:
#newFilterHolder(Class)

getFilter

public FilterHolder getFilter(String name)

addFilterWithMapping

public FilterHolder addFilterWithMapping(Class<? extends Filter> filter,
                                         String pathSpec,
                                         EnumSet<DispatcherType> dispatches)
Convenience method to add a filter.

参数:
filter - class of filter to create
pathSpec - filter mappings for filter
dispatches - see FilterMapping.setDispatches(int)
返回:
The filter holder.

addFilterWithMapping

public FilterHolder addFilterWithMapping(String className,
                                         String pathSpec,
                                         EnumSet<DispatcherType> dispatches)
Convenience method to add a filter.

参数:
className - of filter
pathSpec - filter mappings for filter
dispatches - see FilterMapping.setDispatches(int)
返回:
The filter holder.

addFilterWithMapping

public void addFilterWithMapping(FilterHolder holder,
                                 String pathSpec,
                                 EnumSet<DispatcherType> dispatches)
Convenience method to add a filter.

参数:
holder - filter holder to add
pathSpec - filter mappings for filter
dispatches - see FilterMapping.setDispatches(int)

addFilterWithMapping

public FilterHolder addFilterWithMapping(Class<? extends Filter> filter,
                                         String pathSpec,
                                         int dispatches)
Convenience method to add a filter.

参数:
filter - class of filter to create
pathSpec - filter mappings for filter
dispatches - see FilterMapping.setDispatches(int)
返回:
The filter holder.

addFilterWithMapping

public FilterHolder addFilterWithMapping(String className,
                                         String pathSpec,
                                         int dispatches)
Convenience method to add a filter.

参数:
className - of filter
pathSpec - filter mappings for filter
dispatches - see FilterMapping.setDispatches(int)
返回:
The filter holder.

addFilterWithMapping

public void addFilterWithMapping(FilterHolder holder,
                                 String pathSpec,
                                 int dispatches)
Convenience method to add a filter.

参数:
holder - filter holder to add
pathSpec - filter mappings for filter
dispatches - see FilterMapping.setDispatches(int)

addFilter

public FilterHolder addFilter(String className,
                              String pathSpec,
                              EnumSet<DispatcherType> dispatches)
已过时。 use #addFilterWithMapping(Class, String, EnumSet) instead

Convenience method to add a filter with a mapping

参数:
className -
pathSpec -
dispatches -
返回:
the filter holder created

addFilter

public void addFilter(FilterHolder filter,
                      FilterMapping filterMapping)
convenience method to add a filter and mapping

参数:
filter -
filterMapping -

addFilter

public void addFilter(FilterHolder filter)
Convenience method to add a preconstructed FilterHolder

参数:
filter -

addFilterMapping

public void addFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping

参数:
mapping -

prependFilterMapping

public void prependFilterMapping(FilterMapping mapping)
Convenience method to add a preconstructed FilterMapping

参数:
mapping -

insertFilterMapping

protected FilterMapping[] insertFilterMapping(FilterMapping mapping,
                                              int pos,
                                              boolean before)
Insert a filtermapping in the list

参数:
mapping - the FilterMapping to add
pos - the position in the existing arry at which to add it
before - if true, insert before pos, if false insert after it
返回:

updateNameMappings

protected void updateNameMappings()

updateMappings

protected void updateMappings()

notFound

protected void notFound(HttpServletRequest request,
                        HttpServletResponse response)
                 throws IOException
抛出:
IOException

setFilterChainsCached

public void setFilterChainsCached(boolean filterChainsCached)
参数:
filterChainsCached - The filterChainsCached to set.

setFilterMappings

public void setFilterMappings(FilterMapping[] filterMappings)
参数:
filterMappings - The filterMappings to set.

setFilters

public void setFilters(FilterHolder[] holders)

setServletMappings

public void setServletMappings(ServletMapping[] servletMappings)
参数:
servletMappings - The servletMappings to set.

setServlets

public void setServlets(ServletHolder[] holders)
Set Servlets.

参数:
holders - Array of servletsto define

getMaxFilterChainsCacheSize

public int getMaxFilterChainsCacheSize()
返回:
The maximum entries in a filter chain cache.

setMaxFilterChainsCacheSize

public void setMaxFilterChainsCacheSize(int maxFilterChainsCacheSize)
Set the maximum filter chain cache size. Filter chains are cached if 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.

dump

public void dump(Appendable out,
                 String indent)
          throws IOException
指定者:
接口 Dumpable 中的 dump
覆盖:
AbstractHandlerContainer 中的 dump
抛出:
IOException


Copyright © 2013. All Rights Reserved.