|
Apache Tomcat 7.0.4 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.catalina.core.ApplicationContext
public class ApplicationContext
Standard implementation of ServletContext that represents
a web application's execution environment. An instance of this class is
associated with each instance of StandardContext.
| Field Summary | |
|---|---|
protected Map<String,Object> |
attributes
The context attributes for this context. |
protected static boolean |
GET_RESOURCE_REQUIRE_SLASH
|
protected static boolean |
STRICT_SERVLET_COMPLIANCE
|
| Fields inherited from interface javax.servlet.ServletContext |
|---|
ORDERED_LIBS, TEMPDIR |
| Constructor Summary | |
|---|---|
ApplicationContext(StandardContext context)
Construct a new instance of this class, associated with the specified Context instance. |
|
| Method Summary | ||
|---|---|---|
FilterRegistration.Dynamic |
addFilter(String filterName,
Class<? extends Filter> filterClass)
Add filter to context. |
|
FilterRegistration.Dynamic |
addFilter(String filterName,
Filter filter)
Add filter to context. |
|
FilterRegistration.Dynamic |
addFilter(String filterName,
String filterClass)
Add filter to context. |
|
void |
addListener(Class<? extends EventListener> listenerClass)
|
|
void |
addListener(String className)
|
|
|
addListener(T t)
|
|
ServletRegistration.Dynamic |
addServlet(String servletName,
Class<? extends Servlet> servletClass)
Add servlet to context. |
|
ServletRegistration.Dynamic |
addServlet(String servletName,
Servlet servlet)
Add servlet to context. |
|
ServletRegistration.Dynamic |
addServlet(String servletName,
String servletClass)
Add servlet to context. |
|
protected void |
clearAttributes()
Clear all application-created attributes. |
|
|
createFilter(Class<T> c)
|
|
|
createListener(Class<T> c)
|
|
|
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<String> |
getAttributeNames()
Return an enumeration of the names of the context attributes associated with this context. |
|
ClassLoader |
getClassLoader()
|
|
protected StandardContext |
getContext()
|
|
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<SessionTrackingMode> |
getDefaultSessionTrackingModes()
By default SessionTrackingMode.URL is always supported, SessionTrackingMode.COOKIE is supported unless the cookies
attribute has been set to false for the context and SessionTrackingMode.SSL is supported if at least one of the connectors
used by this context has the attribute secure set to
true. |
|
int |
getEffectiveMajorVersion()
|
|
int |
getEffectiveMinorVersion()
|
|
Set<SessionTrackingMode> |
getEffectiveSessionTrackingModes()
Return the supplied value if one was previously set, else return the defaults. |
|
protected ServletContext |
getFacade()
Return the facade associated with this ApplicationContext. |
|
FilterRegistration |
getFilterRegistration(String filterName)
|
|
Map<String,? extends FilterRegistration> |
getFilterRegistrations()
|
|
String |
getInitParameter(String name)
Return the value of the specified initialization parameter, or null if this parameter does not exist. |
|
Enumeration<String> |
getInitParameterNames()
Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters. |
|
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. |
|
RequestDispatcher |
getNamedDispatcher(String name)
Return a RequestDispatcher object that acts as a
wrapper for the named servlet. |
|
protected Map<String,String> |
getReadonlyAttributes()
|
|
String |
getRealPath(String path)
Return the real path for a given virtual path, if possible; otherwise return null. |
|
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<String> |
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. |
|
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<String> |
getServletNames()
Deprecated. As of Java Servlet API 2.1, with no direct replacement. |
|
ServletRegistration |
getServletRegistration(String servletName)
|
|
Map<String,? extends ServletRegistration> |
getServletRegistrations()
|
|
Enumeration<Servlet> |
getServlets()
Deprecated. As of Java Servlet API 2.1, with no direct replacement. |
|
SessionCookieConfig |
getSessionCookieConfig()
|
|
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)
|
|
protected void |
setNewServletContextListenerAllowed(boolean allowed)
|
|
void |
setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final boolean STRICT_SERVLET_COMPLIANCE
protected static final boolean GET_RESOURCE_REQUIRE_SLASH
protected Map<String,Object> attributes
| Constructor Detail |
|---|
public ApplicationContext(StandardContext context)
context - The associated Context instance| Method Detail |
|---|
public DirContext getResources()
public Object getAttribute(String name)
null.
getAttribute in interface ServletContextname - Name of the context attribute to return
Object containing the value of the attribute, or
null if no attribute exists matching the given nameServletContext.getAttributeNames()public Enumeration<String> getAttributeNames()
getAttributeNames in interface ServletContextEnumeration of attribute namesServletContext.getAttribute(java.lang.String)public 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 ServletContexturi - Absolute URI of a resource on the server
ServletContext object that corresponds to the
named URL, or null if either none exists or the container wishes
to restrict this access.RequestDispatcherpublic String getContextPath()
getContextPath in interface ServletContextpublic String getInitParameter(String name)
null if this parameter does not exist.
getInitParameter in interface ServletContextname - Name of the initialization parameter to retrieve
String containing at least the servlet container
name and version numberServletConfig.getInitParameter(java.lang.String)public Enumeration<String> getInitParameterNames()
getInitParameterNames in interface ServletContextEnumeration of String objects
containing the names of the context's initialization parametersServletConfig.getInitParameter(java.lang.String)public int getMajorVersion()
getMajorVersion in interface ServletContextpublic int getMinorVersion()
getMinorVersion in interface ServletContextpublic String getMimeType(String file)
null if
the MIME type cannot be determined.
getMimeType in interface ServletContextfile - Filename for which to identify a MIME type
String specifying the file's MIME typepublic RequestDispatcher getNamedDispatcher(String name)
RequestDispatcher object that acts as a
wrapper for the named servlet.
getNamedDispatcher in interface ServletContextname - Name of the servlet for which a dispatcher is requested
RequestDispatcher object that acts as a wrapper for
the named servlet, or null if the
ServletContext cannot return a
RequestDispatcherRequestDispatcher,
ServletContext.getContext(java.lang.String),
ServletConfig.getServletName()public String getRealPath(String path)
null.
getRealPath in interface ServletContextpath - The path to the desired resource
String specifying the real path, or null if the
translation cannot be performedpublic 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 ServletContextpath - The path to the desired resource.
RequestDispatcher object that acts as a wrapper for
the resource at the specified path, or null if the
ServletContext cannot return a
RequestDispatcherRequestDispatcher,
ServletContext.getContext(java.lang.String)
public URL getResource(String path)
throws MalformedURLException
getResource in interface ServletContextpath - The path to the desired resource
null if
there is no resource at that path
MalformedURLException - 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 ServletContextpath - The path to the desired resource.
InputStream returned to the servlet, or
null if no resource exists at the specified pathpublic Set<String> getResourcePaths(String path)
getResourcePaths in interface ServletContextpath - Collection path
public String getServerInfo()
getServerInfo in interface ServletContextString containing at least the servlet container
name and version number@Deprecated public Servlet getServlet(String name)
getServlet in interface ServletContextpublic String getServletContextName()
getServletContextName in interface ServletContext@Deprecated public Enumeration<String> getServletNames()
getServletNames in interface ServletContext@Deprecated public Enumeration<Servlet> getServlets()
getServlets in interface ServletContextpublic void log(String message)
log in interface ServletContextmessage - Message to be written
@Deprecated
public void log(Exception exception,
String message)
log(String, Throwable) instead
log in interface ServletContextexception - Exception to be reportedmessage - Message to be written
public void log(String message,
Throwable throwable)
log in interface ServletContextmessage - Message to be writtenthrowable - Exception to be reportedpublic void removeAttribute(String name)
removeAttribute in interface ServletContextname - Name of the context attribute to be removed
public void setAttribute(String name,
Object value)
setAttribute in interface ServletContextname - Attribute name to be boundvalue - New attribute value to be bound
public FilterRegistration.Dynamic addFilter(String filterName,
String filterClass)
throws IllegalStateException
addFilter in interface ServletContextfilterName - Name of filter to addfilterClass - Name of filter class
null if the filter has already been fully defined,
else a FilterRegistration.Dynamic object
that can be used to further configure the filter
IllegalStateException - if the context has already been initialised
UnsupportedOperationException - - if this context was passed to the
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method of a ServletContextListener that was not declared
in web.xml, a web-fragment or annotated with WebListener.
public FilterRegistration.Dynamic addFilter(String filterName,
Filter filter)
throws IllegalStateException
addFilter in interface ServletContextfilterName - Name of filter to addfilter - Filter to add
null if the filter has already been fully defined,
else a FilterRegistration.Dynamic object
that can be used to further configure the filter
IllegalStateException - if the context has already been initialised
UnsupportedOperationException - - if this context was passed to the
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method of a ServletContextListener that was not declared
in web.xml, a web-fragment or annotated with WebListener.
public FilterRegistration.Dynamic addFilter(String filterName,
Class<? extends Filter> filterClass)
throws IllegalStateException
addFilter in interface ServletContextfilterName - Name of filter to addfilterClass - Class of filter to add
null if the filter has already been fully defined,
else a FilterRegistration.Dynamic object
that can be used to further configure the filter
IllegalStateException - if the context has already been initialised
UnsupportedOperationException - - if this context was passed to the
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method of a ServletContextListener that was not declared
in web.xml, a web-fragment or annotated with WebListener.
public <T extends Filter> T createFilter(Class<T> c)
throws ServletException
createFilter in interface ServletContextServletExceptionpublic FilterRegistration getFilterRegistration(String filterName)
getFilterRegistration in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName,
String servletClass)
throws IllegalStateException
addServlet in interface ServletContextservletName - Name of servlet to addservletClass - Name of servlet class
null if the servlet has already been fully defined,
else a ServletRegistration.Dynamic object
that can be used to further configure the servlet
IllegalStateException - if the context has already been initialised
UnsupportedOperationException - - if this context was passed to the
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method of a ServletContextListener that was not declared
in web.xml, a web-fragment or annotated with WebListener.
public ServletRegistration.Dynamic addServlet(String servletName,
Servlet servlet)
throws IllegalStateException
addServlet in interface ServletContextservletName - Name of servlet to addservlet - Servlet instance to add
null if the servlet has already been fully defined,
else a ServletRegistration.Dynamic object
that can be used to further configure the servlet
IllegalStateException - if the context has already been initialised
UnsupportedOperationException - - if this context was passed to the
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method of a ServletContextListener that was not declared
in web.xml, a web-fragment or annotated with WebListener.
public ServletRegistration.Dynamic addServlet(String servletName,
Class<? extends Servlet> servletClass)
throws IllegalStateException
addServlet in interface ServletContextservletName - Name of servlet to addservletClass - Class of servlet to add
null if the servlet has already been fully defined,
else a ServletRegistration.Dynamic object
that can be used to further configure the servlet
IllegalStateException - if the context has already been initialised
UnsupportedOperationException - - if this context was passed to the
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
method of a ServletContextListener that was not declared
in web.xml, a web-fragment or annotated with WebListener.
public <T extends Servlet> T createServlet(Class<T> c)
throws ServletException
createServlet in interface ServletContextServletExceptionpublic ServletRegistration getServletRegistration(String servletName)
getServletRegistration in interface ServletContextpublic Set<SessionTrackingMode> getDefaultSessionTrackingModes()
SessionTrackingMode.URL is always supported, SessionTrackingMode.COOKIE is supported unless the cookies
attribute has been set to false for the context and SessionTrackingMode.SSL is supported if at least one of the connectors
used by this context has the attribute secure set to
true.
getDefaultSessionTrackingModes in interface ServletContextpublic Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes in interface ServletContextpublic SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig in interface ServletContextpublic void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes in interface ServletContextIllegalStateException - if the context has already been initialised
IllegalArgumentException - If SSL is requested in combination with
anything else or if an unsupported
tracking mode is requested
public boolean setInitParameter(String name,
String value)
setInitParameter in interface ServletContextpublic void addListener(Class<? extends EventListener> listenerClass)
addListener in interface ServletContextpublic void addListener(String className)
addListener in interface ServletContextpublic <T extends EventListener> void addListener(T t)
addListener in interface ServletContext
public <T extends EventListener> T createListener(Class<T> c)
throws ServletException
createListener in interface ServletContextServletExceptionpublic void declareRoles(String... roleNames)
declareRoles in interface ServletContextpublic ClassLoader getClassLoader()
getClassLoader in interface ServletContextpublic int getEffectiveMajorVersion()
getEffectiveMajorVersion in interface ServletContextpublic int getEffectiveMinorVersion()
getEffectiveMinorVersion in interface ServletContextpublic Map<String,? extends FilterRegistration> getFilterRegistrations()
getFilterRegistrations in interface ServletContextpublic JspConfigDescriptor getJspConfigDescriptor()
getJspConfigDescriptor in interface ServletContextpublic Map<String,? extends ServletRegistration> getServletRegistrations()
getServletRegistrations in interface ServletContextprotected StandardContext getContext()
protected Map<String,String> getReadonlyAttributes()
protected void clearAttributes()
protected ServletContext getFacade()
protected void setNewServletContextListenerAllowed(boolean allowed)
|
Apache Tomcat 7.0.4 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||