|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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()
Deprecated. |
|
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()
Deprecated. |
|
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 instanceMethod Detail |
---|
@Deprecated public DirContext getResources()
public Object getAttribute(String name)
null
.
getAttribute
in interface ServletContext
name
- 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 ServletContext
Enumeration
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 ServletContext
uri
- 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.RequestDispatcher
public String getContextPath()
getContextPath
in interface ServletContext
public String getInitParameter(String name)
null
if this parameter does not exist.
getInitParameter
in interface ServletContext
name
- 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 ServletContext
Enumeration
of String
objects
containing the names of the context's initialization parametersServletConfig.getInitParameter(java.lang.String)
public int getMajorVersion()
getMajorVersion
in interface ServletContext
public int getMinorVersion()
getMinorVersion
in interface ServletContext
public String getMimeType(String file)
null
if
the MIME type cannot be determined.
getMimeType
in interface ServletContext
file
- 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 ServletContext
name
- 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
RequestDispatcher
RequestDispatcher
,
ServletContext.getContext(java.lang.String)
,
ServletConfig.getServletName()
public String getRealPath(String path)
null
.
getRealPath
in interface ServletContext
path
- 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 ServletContext
path
- 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
RequestDispatcher
RequestDispatcher
,
ServletContext.getContext(java.lang.String)
public URL getResource(String path) throws MalformedURLException
getResource
in interface ServletContext
path
- 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 ServletContext
path
- 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 ServletContext
path
- Collection path
public String getServerInfo()
getServerInfo
in interface ServletContext
String
containing at least the servlet container
name and version number@Deprecated public Servlet getServlet(String name)
getServlet
in interface ServletContext
public String getServletContextName()
getServletContextName
in interface ServletContext
@Deprecated public Enumeration<String> getServletNames()
getServletNames
in interface ServletContext
@Deprecated public Enumeration<Servlet> getServlets()
getServlets
in interface ServletContext
public void log(String message)
log
in interface ServletContext
message
- Message to be written@Deprecated public void log(Exception exception, String message)
log(String, Throwable)
instead
log
in interface ServletContext
exception
- Exception to be reportedmessage
- Message to be writtenpublic void log(String message, Throwable throwable)
log
in interface ServletContext
message
- Message to be writtenthrowable
- Exception to be reportedpublic void removeAttribute(String name)
removeAttribute
in interface ServletContext
name
- Name of the context attribute to be removedpublic void setAttribute(String name, Object value)
setAttribute
in interface ServletContext
name
- Attribute name to be boundvalue
- New attribute value to be boundpublic FilterRegistration.Dynamic addFilter(String filterName, String filterClass) throws IllegalStateException
addFilter
in interface ServletContext
filterName
- 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 ServletContext
filterName
- 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 ServletContext
filterName
- 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 ServletContext
ServletException
public FilterRegistration getFilterRegistration(String filterName)
getFilterRegistration
in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName, String servletClass) throws IllegalStateException
addServlet
in interface ServletContext
servletName
- 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 ServletContext
servletName
- 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 ServletContext
servletName
- 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 ServletContext
ServletException
public ServletRegistration getServletRegistration(String servletName)
getServletRegistration
in interface ServletContext
public 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 ServletContext
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes
in interface ServletContext
public SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig
in interface ServletContext
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes
in interface ServletContext
IllegalStateException
- if the context has already been initialised
IllegalArgumentException
- If SSL is requested in combination with
anything else or if an unsupported
tracking mode is requestedpublic boolean setInitParameter(String name, String value)
setInitParameter
in interface ServletContext
public void addListener(Class<? extends EventListener> listenerClass)
addListener
in interface ServletContext
public void addListener(String className)
addListener
in interface ServletContext
public <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 ServletContext
ServletException
public void declareRoles(String... roleNames)
declareRoles
in interface ServletContext
public ClassLoader getClassLoader()
getClassLoader
in interface ServletContext
public int getEffectiveMajorVersion()
getEffectiveMajorVersion
in interface ServletContext
public int getEffectiveMinorVersion()
getEffectiveMinorVersion
in interface ServletContext
public Map<String,? extends FilterRegistration> getFilterRegistrations()
getFilterRegistrations
in interface ServletContext
public JspConfigDescriptor getJspConfigDescriptor()
getJspConfigDescriptor
in interface ServletContext
public Map<String,? extends ServletRegistration> getServletRegistrations()
getServletRegistrations
in interface ServletContext
protected StandardContext getContext()
@Deprecated protected Map<String,String> getReadonlyAttributes()
protected void clearAttributes()
protected ServletContext getFacade()
protected void setNewServletContextListenerAllowed(boolean allowed)
|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |