This class acts as the foundation for registering listeners, servlets, and filters in an embedded environment.
Additionally, this class implements the the requirements set forth by the Servlet 2.5 specification of
ServletContext, however, it also exposes the dynamic registration API of Servlet 3.0.
Todo
Provide code examples once the api firms up a bit.
| Modifier and Type | Class and Description |
|---|---|
| private static class | WebappContext.
Internal class used as thread-local storage when doing path mapping during dispatch. |
| Modifier and Type | Field and Description |
|---|---|
| private final ConcurrentMap | |
| private final String | |
| private final Map | |
| private final String | |
| private static final Set | |
| protected boolean | |
| private static final Map | |
| private DispatcherHelper | |
| private final String | |
| private final Set | |
| private EventListener[] | |
| private final FilterChainFactory | |
| private final List | filterMaps
The list of filter mappings for this application, in the order they were defined in the deployment descriptor. |
| protected final Map | |
| private static final Logger | |
| private static final int | |
| private static final int | |
| private final Runnable | onDestroyListener
Destroy listener to be registered on |
| private String | |
| private String | |
| private volatile String | |
| private Set | |
| protected final Map | |
| private SessionCookieConfig | sessionCookieConfig
Session cookie config |
| private SessionManager | |
| pack-priv int | |
| private Set | |
| protected final Map | |
| private ClassLoader |
| Access | Constructor and Description |
|---|---|
| protected | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public FilterRegistration | Returns: a FilterRegistration object that may be used to further configure the registered filter, or null if this WebappContext already contains a complete FilterRegistration for a filter with the given filterNamethe name of the filter filterName, final Class<? extends Filter> the class object from which the filter will be instantiated filterClass)Implements jakarta. Adds the filter with the given name and class type to this servlet context. |
| public FilterRegistration | Returns: a FilterRegistration object that may be used to further configure the given filter, or null if this WebappContext already contains a complete FilterRegistration for a filter with the given filterName or if the same filter instance has already been registered with this or another WebappContext in the same containerthe name of the filter filterName, final Filter the filter instance to register filter)Implements jakarta. Registers the given filter instance with this WebappContext under the given filterName. |
| public FilterRegistration | Returns: a FilterRegistration object that may be used to further configure the registered filter, or null if this WebappContext already contains a complete FilterRegistration for a filter with the given filterNamethe name of the filter filterName, final String the fully qualified class name of the filter className)Implements jakarta. Adds the filter with the given name and class name to this servlet context. |
| protected void | addFilterMap(FilterMap
The filter mapping to be added filterMap, boolean true if the given filter mapping should be matched against requests after any declared filter
mappings of this servlet context, and false if it is supposed to be matched before any declared filter mappings of
this servlet context isMatchAfter)Add a filter mapping to this Context. |
| public ServletRegistration. | addJspFile(final String servletName, final String jspFile)
Implements jakarta. Adds the servlet with the given jsp file to this servlet context. |
| public void | addListener(final Class<? extends EventListener> listenerClass)
Implements jakarta. Adds the given listener class to this WebappContext. |
| public void | addListener(String
the fully qualified class name of the listener className)Implements jakarta. Adds the listener with the given class name to this WebappContext. |
| public <T extends EventListener> void | addListener(T eventListener)
Implements jakarta. Adds the given listener to this ServletContext. |
| public ServletRegistration | Returns: a ServletRegistration object that may be used to further configure the registered servlet, or null if this WebappContext already contains a complete ServletRegistration for the given servletNamethe name of the servlet servletName, final Class<? extends Servlet> the class object from which the servlet will be instantiated servletClass)Implements jakarta. Adds the servlet with the given name and class type to this servlet context. |
| public ServletRegistration | Returns: a ServletRegistration object that may be used to further configure the given servlet, or null if this WebappContext already contains a complete ServletRegistration for a servlet with the given servletName or if the same servlet instance has already been registered with this or another WebappContext in the same containerthe name of the servlet servletName, final Servlet the servlet instance to register servlet)Implements jakarta. Registers the given servlet instance with this WebappContext under the given servletName. |
| public ServletRegistration | Returns: a ServletRegistration object that may be used to further configure the registered servlet, or null if this WebappContext already contains a complete ServletRegistration for a servlet with the given servletNamethe name of the servlet servletName, final String the fully qualified class name of the servlet className)Implements jakarta. Adds the servlet with the given name and class name to this servlet context. |
| private void | |
| public void | |
| private void | |
| private void | |
| protected EventListener | Returns: the new EventListener instanceInstantiates the given EventListener class. |
| protected EventListener | Returns: the new EventListener instanceInstantiates the given EventListener class. |
| public <T extends Filter> T | createFilter(Class<T> clazz)
Implements jakarta. Instantiates the given Filter class. |
| private FilterConfigImpl | |
| protected Filter | Returns: the new Filter instanceInstantiates the given Filter class. |
| protected Filter | Returns: the new Filter instanceInstantiates the given Filter class. |
| public <T extends HttpUpgradeHandler> T | Returns: a new T instanceInstantiates the given HttpUpgradeHandler class. |
| public <T extends EventListener> T | createListener(Class<T> clazz)
Implements jakarta. Instantiates the given EventListener class. |
| public <T extends Servlet> T | createServlet(Class<T> clazz)
Implements jakarta. Instantiates the given Servlet class. |
| private ServletConfigImpl | |
| protected Servlet | Returns: the new Servlet instanceInstantiates the given Servlet class. |
| protected Servlet | Returns: the new Servlet instanceInstantiates the given Servlet class. |
| public void | declareRoles(String... roleNames)
Implements jakarta. Declares role names that are tested using |
| public synchronized void | |
| protected void | |
| private void | |
| public Object | getAttribute(String name)
Implements jakarta. Returns the servlet container attribute with the given name, or |
| public Enumeration | getAttributeNames()
Implements jakarta. Returns an |
| protected String | |
| public ClassLoader | getClassLoader()
Implements jakarta. Gets the class loader of the web application represented by this ServletContext. |
| public ServletContext | getContext(String uri)
Implements jakarta. Returns a |
| public String | getContextPath()
Implements jakarta. Returns the context path of the web application. |
| public Set | getDefaultSessionTrackingModes()
Implements jakarta. Gets the session tracking modes that are supported by default for this ServletContext. |
| public int | getEffectiveMajorVersion()
Implements jakarta. Gets the major version of the Servlet specification that the application represented by this ServletContext is based on. |
| public int | getEffectiveMinorVersion()
Implements jakarta. Gets the minor version of the Servlet specification that the application represented by this ServletContext is based on. |
| public Set | getEffectiveSessionTrackingModes()
Implements jakarta. Gets the session tracking modes that are in effect for this ServletContext. |
| protected EventListener[] | |
| protected FilterChainFactory | |
| protected List | |
| public FilterRegistration | Returns: the (complete or preliminary) FilterRegistration for the filter with the given filterName, or null if no FilterRegistration exists under that nameImplements jakarta. Gets the FilterRegistration corresponding to the filter with the given filterName. |
| public Map | Returns: Map of the (complete and preliminary) FilterRegistration objects corresponding to all filters currently registered with this WebappContextImplements jakarta. Gets a (possibly empty) Map of the FilterRegistration objects (keyed by filter name) corresponding to all filters registered with this WebappContext. |
| public String | getInitParameter(String name)
Implements jakarta. Returns a |
| public Enumeration | getInitParameterNames()
Implements jakarta. Returns the names of the context's initialization parameters as an |
| public JspConfigDescriptor | getJspConfigDescriptor()
Implements jakarta. Gets the |
| public int | getMajorVersion()
Implements jakarta. Returns the major version of Jakarta Servlet specification that this container supports. |
| public String | getMimeType(String file)
Implements jakarta. Returns the MIME type of the specified file, or |
| public int | getMinorVersion()
Implements jakarta. Returns the minor version of Jakarta Servlet specification that this container supports. |
| public RequestDispatcher | getNamedDispatcher(String name)
Implements jakarta. Returns a |
| public String | getRealPath(String path)
Implements jakarta. Gets the real path corresponding to the given virtual path. |
| public String | getRequestCharacterEncoding()
Implements jakarta. Gets the request character encoding that are supported by default for this ServletContext. |
| public RequestDispatcher | getRequestDispatcher(String path)
Implements jakarta. Returns a |
| public URL | getResource(String path)
Implements jakarta. Returns a URL to the resource that is mapped to the given path. |
| public InputStream | getResourceAsStream(String path)
Implements jakarta. Returns the resource located at the named path as an |
| public Set | getResourcePaths(String path)
Implements jakarta. Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. |
| public String | getResponseCharacterEncoding()
Implements jakarta. Gets the response character encoding that are supported by default for this ServletContext. |
| public String | getServerInfo()
Implements jakarta. Returns the name and version of the servlet container on which the servlet is running. |
| public String | getServletContextName()
Implements jakarta. Returns the name of this web application corresponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element. |
| protected Collection | getServletNameFilterMappings(String filterName)
Gets the current servlet name mappings of the Filter with the given name. |
| public ServletRegistration | Returns: the (complete or preliminary) ServletRegistration for the servlet with the given servletName, or null if no ServletRegistration exists under that nameImplements jakarta. Gets the ServletRegistration corresponding to the servlet with the given servletName. |
| public Map | Returns: Map of the (complete and preliminary) ServletRegistration objects corresponding to all servlets currently registered with this WebappContextImplements jakarta. Gets a (possibly empty) Map of the ServletRegistration objects (keyed by servlet name) corresponding to all servlets registered with this WebappContext. |
| public SessionCookieConfig | getSessionCookieConfig()
Implements jakarta. Gets the |
| public int | getSessionTimeout()
Implements jakarta. Gets the session timeout in minutes that are supported by default for this ServletContext. |
| protected Collection | getUrlPatternFilterMappings(String filterName)
Gets the current URL pattern mappings of the Filter with the given name. |
| public String | getVirtualServerName()
Implements jakarta. Returns the configuration name of the logical host on which the ServletContext is deployed. |
| private void | |
| private void | |
| private void | |
| public void | log(String message)
Implements jakarta. Writes the specified message to a servlet log file, usually an event log. |
| public void | log(String message, Throwable throwable)
Implements jakarta. Writes an explanatory message and a stack trace for a given |
| protected String | |
| private void | |
| public void | removeAttribute(String name)
Implements jakarta. Removes the attribute with the given name from this ServletContext. |
| public void | |
| protected void | |
| public void | setAttribute(String name, Object value)
Implements jakarta. Binds an object to a given attribute name in this ServletContext. |
| protected void | |
| public boolean | setInitParameter(String name, String value)
Implements jakarta. Sets the context initialization parameter with the given name and value on this ServletContext. |
| public void | setRequestCharacterEncoding(final String requestEncoding)
Implements jakarta. Sets the request character encoding for this ServletContext. |
| public void | setResponseCharacterEncoding(final String responseEncoding)
Implements jakarta. Sets the response character encoding for this ServletContext. |
| public void | setServerInfo(final String
the string to be sent with the response. serverInfo)Set the value of the |
| public void | setSessionManager(SessionManager
an implementation of SessionManager sessionManager)Sets the |
| public void | setSessionTimeout(final int sessionTimeout)
Implements jakarta. Sets the session timeout in minutes for this ServletContext. |
| public void | setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
Implements jakarta. Sets the session tracking modes that are to become effective for this ServletContext. |
| public synchronized void | |
| protected void | |
| protected void | |
| private static String | |
| protected boolean | validateURLPattern(String
URL pattern to be validated urlPattern)Validate the syntax of a proposed |