public class ApplicationContext extends Object implements javax.servlet.ServletContext
ServletContext that represents
a web application's execution environment. An instance of this class is
associated with each instance of StandardContext.| Modifier and Type | Field and Description |
|---|---|
protected Map |
attributes
The context attributes for this context.
|
| Constructor and Description |
|---|
ApplicationContext(String basePath,
StandardContext context)
Construct a new instance of this class, associated with the specified
Context instance.
|
| Modifier and Type | Method and Description |
|---|---|
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
Class<? extends javax.servlet.Filter> filterClass) |
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
javax.servlet.Filter filter) |
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
String className) |
void |
addListener(Class<? extends EventListener> listenerClass) |
void |
addListener(String className) |
<T extends EventListener> |
addListener(T listener) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
Class<? extends javax.servlet.Servlet> clazz) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
javax.servlet.Servlet servlet) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
String className) |
protected void |
checkListenerType(EventListener listener) |
protected void |
clearAttributes()
Clear all application-created attributes.
|
<T extends javax.servlet.Filter> |
createFilter(Class<T> c) |
<T extends EventListener> |
createListener(Class<T> clazz) |
<T extends javax.servlet.Servlet> |
createServlet(Class<T> c) |
void |
declareRoles(String... roleNames) |
Object |
getAttribute(String name)
Return the value of the specified context attribute, if any;
otherwise return
null. |
Enumeration |
getAttributeNames()
Return an enumeration of the names of the context attributes
associated with this context.
|
ClassLoader |
getClassLoader() |
protected StandardContext |
getContext() |
javax.servlet.ServletContext |
getContext(String uri)
Return a
ServletContext object that corresponds to a
specified URI on the server. |
String |
getContextPath()
Return the main path associated with this context.
|
Set<javax.servlet.SessionTrackingMode> |
getDefaultSessionTrackingModes() |
int |
getEffectiveMajorVersion() |
int |
getEffectiveMinorVersion() |
Set<javax.servlet.SessionTrackingMode> |
getEffectiveSessionTrackingModes() |
protected javax.servlet.ServletContext |
getFacade()
Return the facade associated with this ApplicationContext.
|
javax.servlet.FilterRegistration |
getFilterRegistration(String filterName) |
Map<String,javax.servlet.FilterRegistration> |
getFilterRegistrations() |
String |
getInitParameter(String name)
Return the value of the specified initialization parameter, or
null if this parameter does not exist. |
Enumeration |
getInitParameterNames()
Return the names of the context's initialization parameters, or an
empty enumeration if the context has no initialization parameters.
|
javax.servlet.descriptor.JspConfigDescriptor |
getJspConfigDescriptor() |
int |
getMajorVersion()
Return the major version of the Java Servlet API that we implement.
|
String |
getMimeType(String file)
Return the MIME type of the specified file, or
null if
the MIME type cannot be determined. |
int |
getMinorVersion()
Return the minor version of the Java Servlet API that we implement.
|
javax.servlet.RequestDispatcher |
getNamedDispatcher(String name)
Return a
RequestDispatcher object that acts as a
wrapper for the named servlet. |
protected Map |
getReadonlyAttributes() |
String |
getRealPath(String path)
Return the real path for a given virtual path, if possible; otherwise
return
null. |
javax.servlet.RequestDispatcher |
getRequestDispatcher(String path)
Return a
RequestDispatcher instance that acts as a
wrapper for the resource at the given path. |
URL |
getResource(String path)
Return the URL to the resource that is mapped to a specified path.
|
InputStream |
getResourceAsStream(String path)
Return the requested resource as an
InputStream. |
Set |
getResourcePaths(String path)
Return a Set containing the resource paths of resources member of the
specified collection.
|
DirContext |
getResources()
Return the resources object that is mapped to a specified path.
|
String |
getServerInfo()
Return the name and version of the servlet container.
|
javax.servlet.Servlet |
getServlet(String name)
Deprecated.
As of Java Servlet API 2.1, with no direct replacement.
|
String |
getServletContextName()
Return the display name of this web application.
|
Enumeration |
getServletNames()
Deprecated.
As of Java Servlet API 2.1, with no direct replacement.
|
javax.servlet.ServletRegistration |
getServletRegistration(String servletName) |
Map<String,javax.servlet.ServletRegistration> |
getServletRegistrations() |
Enumeration |
getServlets()
Deprecated.
As of Java Servlet API 2.1, with no direct replacement.
|
javax.servlet.SessionCookieConfig |
getSessionCookieConfig() |
String |
getVirtualServerName() |
boolean |
isRestricted() |
void |
log(Exception exception,
String message)
Deprecated.
As of Java Servlet API 2.1, use
log(String, Throwable) instead |
void |
log(String message)
Writes the specified message to a servlet log file.
|
void |
log(String message,
Throwable throwable)
Writes the specified message and exception to a servlet log file.
|
void |
removeAttribute(String name)
Remove the context attribute with the specified name, if any.
|
void |
setAttribute(String name,
Object value)
Bind the specified value with the specified context attribute name,
replacing any existing value for that name.
|
boolean |
setInitParameter(String name,
String value) |
void |
setRestricted(boolean restricted) |
void |
setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes) |
protected Map attributes
public ApplicationContext(String basePath, StandardContext context)
context - The associated Context instancepublic DirContext getResources()
public boolean isRestricted()
public void setRestricted(boolean restricted)
public Object getAttribute(String name)
null.getAttribute in interface javax.servlet.ServletContextname - Name of the context attribute to returnpublic Enumeration getAttributeNames()
getAttributeNames in interface javax.servlet.ServletContextpublic javax.servlet.ServletContext getContext(String uri)
ServletContext object that corresponds to a
specified URI on the server. This method allows servlets to gain
access to the context for various parts of the server, and as needed
obtain RequestDispatcher objects or resources from the
context. The given path must be absolute (beginning with a "/"),
and is interpreted based on our virtual host's document root.getContext in interface javax.servlet.ServletContexturi - Absolute URI of a resource on the serverpublic String getContextPath()
getContextPath in interface javax.servlet.ServletContextpublic String getInitParameter(String name)
null if this parameter does not exist.getInitParameter in interface javax.servlet.ServletContextname - Name of the initialization parameter to retrievepublic Enumeration getInitParameterNames()
getInitParameterNames in interface javax.servlet.ServletContextpublic int getMajorVersion()
getMajorVersion in interface javax.servlet.ServletContextpublic int getMinorVersion()
getMinorVersion in interface javax.servlet.ServletContextpublic String getMimeType(String file)
null if
the MIME type cannot be determined.getMimeType in interface javax.servlet.ServletContextfile - Filename for which to identify a MIME typepublic javax.servlet.RequestDispatcher getNamedDispatcher(String name)
RequestDispatcher object that acts as a
wrapper for the named servlet.getNamedDispatcher in interface javax.servlet.ServletContextname - Name of the servlet for which a dispatcher is requestedpublic String getRealPath(String path)
null.getRealPath in interface javax.servlet.ServletContextpath - The path to the desired resourcepublic javax.servlet.RequestDispatcher getRequestDispatcher(String path)
RequestDispatcher instance that acts as a
wrapper for the resource at the given path. The path must begin
with a "/" and is interpreted as relative to the current context root.getRequestDispatcher in interface javax.servlet.ServletContextpath - The path to the desired resource.public URL getResource(String path) throws MalformedURLException
getResource in interface javax.servlet.ServletContextpath - The path to the desired resourceMalformedURLException - if the path is not given
in the correct formpublic InputStream getResourceAsStream(String path)
InputStream. The
path must be specified according to the rules described under
getResource. If no such resource can be identified,
return null.getResourceAsStream in interface javax.servlet.ServletContextpath - The path to the desired resource.public Set getResourcePaths(String path)
getResourcePaths in interface javax.servlet.ServletContextpath - Collection pathpublic String getServerInfo()
getServerInfo in interface javax.servlet.ServletContextpublic javax.servlet.Servlet getServlet(String name)
getServlet in interface javax.servlet.ServletContextpublic String getServletContextName()
getServletContextName in interface javax.servlet.ServletContextpublic Enumeration getServletNames()
getServletNames in interface javax.servlet.ServletContextpublic Enumeration getServlets()
getServlets in interface javax.servlet.ServletContextpublic void log(String message)
log in interface javax.servlet.ServletContextmessage - Message to be writtenpublic void log(Exception exception, String message)
log(String, Throwable) insteadlog in interface javax.servlet.ServletContextexception - Exception to be reportedmessage - Message to be writtenpublic void log(String message, Throwable throwable)
log in interface javax.servlet.ServletContextmessage - Message to be writtenthrowable - Exception to be reportedpublic void removeAttribute(String name)
removeAttribute in interface javax.servlet.ServletContextname - Name of the context attribute to be removedpublic void setAttribute(String name, Object value)
setAttribute in interface javax.servlet.ServletContextname - Attribute name to be boundvalue - New attribute value to be boundpublic javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className) throws IllegalArgumentException, IllegalStateException
addFilter in interface javax.servlet.ServletContextIllegalArgumentExceptionIllegalStateExceptionpublic javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, javax.servlet.Filter filter)
addFilter in interface javax.servlet.ServletContextpublic javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends javax.servlet.Filter> filterClass)
addFilter in interface javax.servlet.ServletContextpublic javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className) throws IllegalArgumentException, IllegalStateException
addServlet in interface javax.servlet.ServletContextIllegalArgumentExceptionIllegalStateExceptionpublic javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends javax.servlet.Servlet> clazz) throws IllegalArgumentException, IllegalStateException
addServlet in interface javax.servlet.ServletContextIllegalArgumentExceptionIllegalStateExceptionpublic javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, javax.servlet.Servlet servlet)
addServlet in interface javax.servlet.ServletContextpublic javax.servlet.FilterRegistration getFilterRegistration(String filterName)
getFilterRegistration in interface javax.servlet.ServletContextpublic javax.servlet.ServletRegistration getServletRegistration(String servletName)
getServletRegistration in interface javax.servlet.ServletContextpublic Map<String,javax.servlet.FilterRegistration> getFilterRegistrations()
getFilterRegistrations in interface javax.servlet.ServletContextpublic Map<String,javax.servlet.ServletRegistration> getServletRegistrations()
getServletRegistrations in interface javax.servlet.ServletContextpublic Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
getDefaultSessionTrackingModes in interface javax.servlet.ServletContextpublic Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes in interface javax.servlet.ServletContextpublic javax.servlet.SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig in interface javax.servlet.ServletContextpublic <T extends javax.servlet.Filter> T createFilter(Class<T> c) throws javax.servlet.ServletException
createFilter in interface javax.servlet.ServletContextjavax.servlet.ServletExceptionpublic <T extends javax.servlet.Servlet> T createServlet(Class<T> c) throws javax.servlet.ServletException
createServlet in interface javax.servlet.ServletContextjavax.servlet.ServletExceptionpublic boolean setInitParameter(String name, String value)
setInitParameter in interface javax.servlet.ServletContextpublic void setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes in interface javax.servlet.ServletContextpublic void addListener(String className)
addListener in interface javax.servlet.ServletContextpublic <T extends EventListener> void addListener(T listener)
addListener in interface javax.servlet.ServletContextpublic void addListener(Class<? extends EventListener> listenerClass)
addListener in interface javax.servlet.ServletContextpublic <T extends EventListener> T createListener(Class<T> clazz) throws javax.servlet.ServletException
createListener in interface javax.servlet.ServletContextjavax.servlet.ServletExceptionpublic ClassLoader getClassLoader()
getClassLoader in interface javax.servlet.ServletContextpublic javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
getJspConfigDescriptor in interface javax.servlet.ServletContextpublic int getEffectiveMajorVersion()
getEffectiveMajorVersion in interface javax.servlet.ServletContextpublic int getEffectiveMinorVersion()
getEffectiveMinorVersion in interface javax.servlet.ServletContextpublic void declareRoles(String... roleNames)
declareRoles in interface javax.servlet.ServletContextpublic String getVirtualServerName()
getVirtualServerName in interface javax.servlet.ServletContextprotected void checkListenerType(EventListener listener)
protected StandardContext getContext()
protected Map getReadonlyAttributes()
protected void clearAttributes()
protected javax.servlet.ServletContext getFacade()
Copyright © 2016 JBoss by Red Hat. All rights reserved.