org.apache.catalina.core
Class ApplicationContext

java.lang.Object
  extended by org.apache.catalina.core.ApplicationContext
All Implemented Interfaces:
javax.servlet.ServletContext

public class ApplicationContext
extends java.lang.Object
implements javax.servlet.ServletContext

Standard implementation of ServletContext that represents a web application's execution environment. An instance of this class is associated with each instance of StandardContext.

Version:
$Revision: 1263 $ $Date: 2009-11-11 04:29:33 +0100 (Wed, 11 Nov 2009) $
Author:
Craig R. McClanahan, Remy Maucherat

Field Summary
protected  java.util.Map attributes
          The context attributes for this context.
 
Fields inherited from interface javax.servlet.ServletContext
ORDERED_LIBS, TEMPDIR
 
Constructor Summary
ApplicationContext(java.lang.String basePath, StandardContext context)
          Construct a new instance of this class, associated with the specified Context instance.
 
Method Summary
 javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName, java.lang.Class<? extends javax.servlet.Filter> filterClass)
          Adds the filter with the given name and class type to this servlet context.
 javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName, javax.servlet.Filter filter)
          Registers the given filter instance with this ServletContext under the given filterName.
 javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName, java.lang.String className)
          Adds the filter with the given name and class name to this servlet context.
 void addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)
          Adds a listener of the given class type to this ServletContext.
 void addListener(java.lang.String className)
          Adds the listener with the given class name to this ServletContext.
<T extends java.util.EventListener>
void
addListener(T listener)
          Adds the given listener to this ServletContext.
 javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.Class<? extends javax.servlet.Servlet> clazz)
          Adds the servlet with the given name and class type to this servlet context.
 javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName, javax.servlet.Servlet servlet)
          Registers the given servlet instance with this ServletContext under the given servletName.
 javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.String className)
          Adds the servlet with the given name and class name to this servlet context.
protected  void checkListenerType(java.util.EventListener listener)
           
protected  void clearAttributes()
          Clear all application-created attributes.
<T extends javax.servlet.Filter>
T
createFilter(java.lang.Class<T> c)
          Instantiates the given Filter class.
<T extends java.util.EventListener>
T
createListener(java.lang.Class<T> clazz)
          Instantiates the given EventListener class.
<T extends javax.servlet.Servlet>
T
createServlet(java.lang.Class<T> c)
          Instantiates the given Servlet class.
 void declareRoles(java.lang.String... roleNames)
          Declares role names that are tested using isUserInRole.
 java.lang.Object getAttribute(java.lang.String name)
          Return the value of the specified context attribute, if any; otherwise return null.
 java.util.Enumeration getAttributeNames()
          Return an enumeration of the names of the context attributes associated with this context.
 java.lang.ClassLoader getClassLoader()
          Gets the class loader of the web application represented by this ServletContext.
protected  StandardContext getContext()
           
 javax.servlet.ServletContext getContext(java.lang.String uri)
          Return a ServletContext object that corresponds to a specified URI on the server.
 java.lang.String getContextPath()
          Return the main path associated with this context.
 java.util.Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
          Gets the session tracking modes that are supported by default for this ServletContext.
 int getEffectiveMajorVersion()
          Gets the major version of the Servlet specification that the application represented by this ServletContext is based on.
 int getEffectiveMinorVersion()
          Gets the minor version of the Servlet specification that the application represented by this ServletContext is based on.
 java.util.Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
          Gets the session tracking modes that are in effect for this ServletContext.
protected  javax.servlet.ServletContext getFacade()
          Return the facade associated with this ApplicationContext.
 javax.servlet.FilterRegistration getFilterRegistration(java.lang.String filterName)
          Gets the FilterRegistration corresponding to the filter with the given filterName.
 java.util.Map<java.lang.String,javax.servlet.FilterRegistration> getFilterRegistrations()
          Gets a (possibly empty) Map of the FilterRegistration objects (keyed by filter name) corresponding to all filters registered with this ServletContext.
 java.lang.String getInitParameter(java.lang.String name)
          Return the value of the specified initialization parameter, or null if this parameter does not exist.
 java.util.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()
          Gets the <jsp-config> related configuration that was aggregated from the web.xml and web-fragment.xml descriptor files of the web application represented by this ServletContext.
 int getMajorVersion()
          Return the major version of the Java Servlet API that we implement.
 java.lang.String getMimeType(java.lang.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(java.lang.String name)
          Return a RequestDispatcher object that acts as a wrapper for the named servlet.
protected  java.util.Map getReadonlyAttributes()
           
 java.lang.String getRealPath(java.lang.String path)
          Return the real path for a given virtual path, if possible; otherwise return null.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
          Return a RequestDispatcher instance that acts as a wrapper for the resource at the given path.
 java.net.URL getResource(java.lang.String path)
          Return the URL to the resource that is mapped to a specified path.
 java.io.InputStream getResourceAsStream(java.lang.String path)
          Return the requested resource as an InputStream.
 java.util.Set getResourcePaths(java.lang.String path)
          Return a Set containing the resource paths of resources member of the specified collection.
 javax.naming.directory.DirContext getResources()
          Return the resources object that is mapped to a specified path.
 java.lang.String getServerInfo()
          Return the name and version of the servlet container.
 javax.servlet.Servlet getServlet(java.lang.String name)
          Deprecated. As of Java Servlet API 2.1, with no direct replacement.
 java.lang.String getServletContextName()
          Return the display name of this web application.
 java.util.Enumeration getServletNames()
          Deprecated. As of Java Servlet API 2.1, with no direct replacement.
 javax.servlet.ServletRegistration getServletRegistration(java.lang.String servletName)
          Gets the ServletRegistration corresponding to the servlet with the given servletName.
 java.util.Map<java.lang.String,javax.servlet.ServletRegistration> getServletRegistrations()
          Gets a (possibly empty) Map of the ServletRegistration objects (keyed by servlet name) corresponding to all servlets registered with this ServletContext.
 java.util.Enumeration getServlets()
          Deprecated. As of Java Servlet API 2.1, with no direct replacement.
 javax.servlet.SessionCookieConfig getSessionCookieConfig()
          Gets the SessionCookieConfig object through which various properties of the session tracking cookies created on behalf of this ServletContext may be configured.
 boolean isRestricted()
           
 void log(java.lang.Exception exception, java.lang.String message)
          Deprecated. As of Java Servlet API 2.1, use log(String, Throwable) instead
 void log(java.lang.String message)
          Writes the specified message to a servlet log file.
 void log(java.lang.String message, java.lang.Throwable throwable)
          Writes the specified message and exception to a servlet log file.
 void removeAttribute(java.lang.String name)
          Remove the context attribute with the specified name, if any.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Bind the specified value with the specified context attribute name, replacing any existing value for that name.
 boolean setInitParameter(java.lang.String name, java.lang.String value)
          Sets the context initialization parameter with the given name and value on this ServletContext.
 void setRestricted(boolean restricted)
           
 void setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
          Sets the session tracking modes that are to become effective for this ServletContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributes

protected java.util.Map attributes
The context attributes for this context.

Constructor Detail

ApplicationContext

public ApplicationContext(java.lang.String basePath,
                          StandardContext context)
Construct a new instance of this class, associated with the specified Context instance.

Parameters:
context - The associated Context instance
Method Detail

getResources

public javax.naming.directory.DirContext getResources()
Return the resources object that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root.


isRestricted

public boolean isRestricted()

setRestricted

public void setRestricted(boolean restricted)

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Return the value of the specified context attribute, if any; otherwise return null.

Specified by:
getAttribute in interface javax.servlet.ServletContext
Parameters:
name - Name of the context attribute to return
Returns:
an Object containing the value of the attribute, or null if no attribute exists matching the given name
See Also:
ServletContext.getAttributeNames()

getAttributeNames

public java.util.Enumeration getAttributeNames()
Return an enumeration of the names of the context attributes associated with this context.

Specified by:
getAttributeNames in interface javax.servlet.ServletContext
Returns:
an Enumeration of attribute names
See Also:
ServletContext.getAttribute(java.lang.String)

getContext

public javax.servlet.ServletContext getContext(java.lang.String uri)
Return a 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.

Specified by:
getContext in interface javax.servlet.ServletContext
Parameters:
uri - Absolute URI of a resource on the server
Returns:
the ServletContext object that corresponds to the named URL, or null if either none exists or the container wishes to restrict this access.
See Also:
RequestDispatcher

getContextPath

public java.lang.String getContextPath()
Return the main path associated with this context.

Specified by:
getContextPath in interface javax.servlet.ServletContext
Returns:
The context path of the web application, or "" for the default (root) context
See Also:
HttpServletRequest.getContextPath()

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Return the value of the specified initialization parameter, or null if this parameter does not exist.

Specified by:
getInitParameter in interface javax.servlet.ServletContext
Parameters:
name - Name of the initialization parameter to retrieve
Returns:
a String containing at least the servlet container name and version number
See Also:
ServletConfig.getInitParameter(java.lang.String)

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters.

Specified by:
getInitParameterNames in interface javax.servlet.ServletContext
Returns:
an Enumeration of String objects containing the names of the context's initialization parameters
See Also:
ServletConfig.getInitParameter(java.lang.String)

getMajorVersion

public int getMajorVersion()
Return the major version of the Java Servlet API that we implement.

Specified by:
getMajorVersion in interface javax.servlet.ServletContext
Returns:
3

getMinorVersion

public int getMinorVersion()
Return the minor version of the Java Servlet API that we implement.

Specified by:
getMinorVersion in interface javax.servlet.ServletContext
Returns:
0

getMimeType

public java.lang.String getMimeType(java.lang.String file)
Return the MIME type of the specified file, or null if the MIME type cannot be determined.

Specified by:
getMimeType in interface javax.servlet.ServletContext
Parameters:
file - Filename for which to identify a MIME type
Returns:
a String specifying the file's MIME type

getNamedDispatcher

public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
Return a RequestDispatcher object that acts as a wrapper for the named servlet.

Specified by:
getNamedDispatcher in interface javax.servlet.ServletContext
Parameters:
name - Name of the servlet for which a dispatcher is requested
Returns:
a RequestDispatcher object that acts as a wrapper for the named servlet, or null if the ServletContext cannot return a RequestDispatcher
See Also:
RequestDispatcher, ServletContext.getContext(java.lang.String), ServletConfig.getServletName()

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Return the real path for a given virtual path, if possible; otherwise return null.

Specified by:
getRealPath in interface javax.servlet.ServletContext
Parameters:
path - The path to the desired resource
Returns:
the real path, or null if the translation cannot be performed

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
Return a 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.

Specified by:
getRequestDispatcher in interface javax.servlet.ServletContext
Parameters:
path - The path to the desired resource.
Returns:
a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the ServletContext cannot return a RequestDispatcher
See Also:
RequestDispatcher, ServletContext.getContext(java.lang.String)

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException
Return the URL to the resource that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root.

Specified by:
getResource in interface javax.servlet.ServletContext
Parameters:
path - The path to the desired resource
Returns:
the resource located at the named path, or null if there is no resource at that path
Throws:
java.net.MalformedURLException - if the path is not given in the correct form

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Return the requested resource as an InputStream. The path must be specified according to the rules described under getResource. If no such resource can be identified, return null.

Specified by:
getResourceAsStream in interface javax.servlet.ServletContext
Parameters:
path - The path to the desired resource.
Returns:
the InputStream returned to the servlet, or null if no resource exists at the specified path

getResourcePaths

public java.util.Set getResourcePaths(java.lang.String path)
Return a Set containing the resource paths of resources member of the specified collection. Each path will be a String starting with a "/" character. The returned set is immutable.

Specified by:
getResourcePaths in interface javax.servlet.ServletContext
Parameters:
path - Collection path
Returns:
a Set containing the directory listing, or null if there are no resources in the web application whose path begins with the supplied path.

getServerInfo

public java.lang.String getServerInfo()
Return the name and version of the servlet container.

Specified by:
getServerInfo in interface javax.servlet.ServletContext
Returns:
a String containing at least the servlet container name and version number

getServlet

public javax.servlet.Servlet getServlet(java.lang.String name)
Deprecated. As of Java Servlet API 2.1, with no direct replacement.

Specified by:
getServlet in interface javax.servlet.ServletContext

getServletContextName

public java.lang.String getServletContextName()
Return the display name of this web application.

Specified by:
getServletContextName in interface javax.servlet.ServletContext
Returns:
The name of the web application or null if no name has been declared in the deployment descriptor.

getServletNames

public java.util.Enumeration getServletNames()
Deprecated. As of Java Servlet API 2.1, with no direct replacement.

Specified by:
getServletNames in interface javax.servlet.ServletContext

getServlets

public java.util.Enumeration getServlets()
Deprecated. As of Java Servlet API 2.1, with no direct replacement.

Specified by:
getServlets in interface javax.servlet.ServletContext

log

public void log(java.lang.String message)
Writes the specified message to a servlet log file.

Specified by:
log in interface javax.servlet.ServletContext
Parameters:
message - Message to be written

log

public void log(java.lang.Exception exception,
                java.lang.String message)
Deprecated. As of Java Servlet API 2.1, use log(String, Throwable) instead

Writes the specified exception and message to a servlet log file.

Specified by:
log in interface javax.servlet.ServletContext
Parameters:
exception - Exception to be reported
message - Message to be written

log

public void log(java.lang.String message,
                java.lang.Throwable throwable)
Writes the specified message and exception to a servlet log file.

Specified by:
log in interface javax.servlet.ServletContext
Parameters:
message - Message to be written
throwable - Exception to be reported

removeAttribute

public void removeAttribute(java.lang.String name)
Remove the context attribute with the specified name, if any.

Specified by:
removeAttribute in interface javax.servlet.ServletContext
Parameters:
name - Name of the context attribute to be removed

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Bind the specified value with the specified context attribute name, replacing any existing value for that name.

Specified by:
setAttribute in interface javax.servlet.ServletContext
Parameters:
name - Attribute name to be bound
value - New attribute value to be bound

addFilter

public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName,
                                                          java.lang.String className)
                                                   throws java.lang.IllegalArgumentException,
                                                          java.lang.IllegalStateException
Description copied from interface: javax.servlet.ServletContext
Adds the filter with the given name and class name to this servlet context.

The registered filter may be further configured via the returned FilterRegistration object.

The specified className will be loaded using the classloader associated with the application represented by this ServletContext.

If this ServletContext already contains a preliminary FilterRegistration for a filter with the given filterName, it will be completed (by assigning the given className to it) and returned.

This method supports resource injection if the class with the given className represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
addFilter in interface javax.servlet.ServletContext
Parameters:
filterName - the name of the filter
className - the fully qualified class name of the filter
Returns:
a FilterRegistration object that may be used to further configure the registered filter, or null if this ServletContext already contains a complete FilterRegistration for a filter with the given filterName
Throws:
java.lang.IllegalStateException - if this ServletContext has already been initialized
java.lang.IllegalArgumentException

addFilter

public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName,
                                                          javax.servlet.Filter filter)
Description copied from interface: javax.servlet.ServletContext
Registers the given filter instance with this ServletContext under the given filterName.

The registered filter may be further configured via the returned FilterRegistration object.

If this ServletContext already contains a preliminary FilterRegistration for a filter with the given filterName, it will be completed (by assigning the class name of the given filter instance to it) and returned.

Specified by:
addFilter in interface javax.servlet.ServletContext
Parameters:
filterName - the name of the filter
filter - the filter instance to register
Returns:
a FilterRegistration object that may be used to further configure the given filter, or null if this ServletContext 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 ServletContext in the same container

addFilter

public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String filterName,
                                                          java.lang.Class<? extends javax.servlet.Filter> filterClass)
Description copied from interface: javax.servlet.ServletContext
Adds the filter with the given name and class type to this servlet context.

The registered filter may be further configured via the returned FilterRegistration object.

If this ServletContext already contains a preliminary FilterRegistration for a filter with the given filterName, it will be completed (by assigning the name of the given filterClass to it) and returned.

This method supports resource injection if the given filterClass represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
addFilter in interface javax.servlet.ServletContext
Parameters:
filterName - the name of the filter
filterClass - the class object from which the filter will be instantiated
Returns:
a FilterRegistration object that may be used to further configure the registered filter, or null if this ServletContext already contains a complete FilterRegistration for a filter with the given filterName

addServlet

public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName,
                                                            java.lang.String className)
                                                     throws java.lang.IllegalArgumentException,
                                                            java.lang.IllegalStateException
Description copied from interface: javax.servlet.ServletContext
Adds the servlet with the given name and class name to this servlet context.

The registered servlet may be further configured via the returned ServletRegistration object.

The specified className will be loaded using the classloader associated with the application represented by this ServletContext.

If this ServletContext already contains a preliminary ServletRegistration for a servlet with the given servletName, it will be completed (by assigning the given className to it) and returned.

This method introspects the class with the given className for the ServletSecurity, MultipartConfig, javax.annotation.security.RunAs, and javax.annotation.security.DeclareRoles annotations. In addition, this method supports resource injection if the class with the given className represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
addServlet in interface javax.servlet.ServletContext
Parameters:
servletName - the name of the servlet
className - the fully qualified class name of the servlet
Returns:
a ServletRegistration object that may be used to further configure the registered servlet, or null if this ServletContext already contains a complete ServletRegistration for a servlet with the given servletName
Throws:
java.lang.IllegalStateException - if this ServletContext has already been initialized
java.lang.IllegalArgumentException

addServlet

public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName,
                                                            java.lang.Class<? extends javax.servlet.Servlet> clazz)
                                                     throws java.lang.IllegalArgumentException,
                                                            java.lang.IllegalStateException
Description copied from interface: javax.servlet.ServletContext
Adds the servlet with the given name and class type to this servlet context.

The registered servlet may be further configured via the returned ServletRegistration object.

If this ServletContext already contains a preliminary ServletRegistration for a servlet with the given servletName, it will be completed (by assigning the name of the given servletClass to it) and returned.

This method introspects the given servletClass for the ServletSecurity, MultipartConfig, javax.annotation.security.RunAs, and javax.annotation.security.DeclareRoles annotations. In addition, this method supports resource injection if the given servletClass represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
addServlet in interface javax.servlet.ServletContext
Parameters:
servletName - the name of the servlet
clazz - the class object from which the servlet will be instantiated
Returns:
a ServletRegistration object that may be used to further configure the registered servlet, or null if this ServletContext already contains a complete ServletRegistration for the given servletName
Throws:
java.lang.IllegalStateException - if this ServletContext has already been initialized
java.lang.IllegalArgumentException

addServlet

public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String servletName,
                                                            javax.servlet.Servlet servlet)
Description copied from interface: javax.servlet.ServletContext
Registers the given servlet instance with this ServletContext under the given servletName.

The registered servlet may be further configured via the returned ServletRegistration object.

If this ServletContext already contains a preliminary ServletRegistration for a servlet with the given servletName, it will be completed (by assigning the class name of the given servlet instance to it) and returned.

Specified by:
addServlet in interface javax.servlet.ServletContext
Parameters:
servletName - the name of the servlet
servlet - the servlet instance to register
Returns:
a ServletRegistration object that may be used to further configure the given servlet, or null if this ServletContext 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 ServletContext in the same container

getFilterRegistration

public javax.servlet.FilterRegistration getFilterRegistration(java.lang.String filterName)
Description copied from interface: javax.servlet.ServletContext
Gets the FilterRegistration corresponding to the filter with the given filterName.

Specified by:
getFilterRegistration in interface javax.servlet.ServletContext
Returns:
the (complete or preliminary) FilterRegistration for the filter with the given filterName, or null if no FilterRegistration exists under that name

getServletRegistration

public javax.servlet.ServletRegistration getServletRegistration(java.lang.String servletName)
Description copied from interface: javax.servlet.ServletContext
Gets the ServletRegistration corresponding to the servlet with the given servletName.

Specified by:
getServletRegistration in interface javax.servlet.ServletContext
Returns:
the (complete or preliminary) ServletRegistration for the servlet with the given servletName, or null if no ServletRegistration exists under that name

getFilterRegistrations

public java.util.Map<java.lang.String,javax.servlet.FilterRegistration> getFilterRegistrations()
Description copied from interface: javax.servlet.ServletContext
Gets a (possibly empty) Map of the FilterRegistration objects (keyed by filter name) corresponding to all filters registered with this ServletContext.

The returned Map includes the FilterRegistration objects corresponding to all declared and annotated filters, as well as the FilterRegistration objects corresponding to all filters that have been added via one of the addFilter methods.

Any changes to the returned Map must not affect this ServletContext.

Specified by:
getFilterRegistrations in interface javax.servlet.ServletContext
Returns:
Map of the (complete and preliminary) FilterRegistration objects corresponding to all filters currently registered with this ServletContext

getServletRegistrations

public java.util.Map<java.lang.String,javax.servlet.ServletRegistration> getServletRegistrations()
Description copied from interface: javax.servlet.ServletContext
Gets a (possibly empty) Map of the ServletRegistration objects (keyed by servlet name) corresponding to all servlets registered with this ServletContext.

The returned Map includes the ServletRegistration objects corresponding to all declared and annotated servlets, as well as the ServletRegistration objects corresponding to all servlets that have been added via one of the addServlet methods.

Any changes to the returned Map must not affect this ServletContext.

Specified by:
getServletRegistrations in interface javax.servlet.ServletContext
Returns:
Map of the (complete and preliminary) ServletRegistration objects corresponding to all servlets currently registered with this ServletContext

getDefaultSessionTrackingModes

public java.util.Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
Description copied from interface: javax.servlet.ServletContext
Gets the session tracking modes that are supported by default for this ServletContext.

Specified by:
getDefaultSessionTrackingModes in interface javax.servlet.ServletContext
Returns:
set of the session tracking modes supported by default for this ServletContext

getEffectiveSessionTrackingModes

public java.util.Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
Description copied from interface: javax.servlet.ServletContext
Gets the session tracking modes that are in effect for this ServletContext.

The session tracking modes in effect are those provided to setSessionTrackingModes.

By default, the session tracking modes returned by getDefaultSessionTrackingModes are in effect.

Specified by:
getEffectiveSessionTrackingModes in interface javax.servlet.ServletContext
Returns:
set of the session tracking modes in effect for this ServletContext

getSessionCookieConfig

public javax.servlet.SessionCookieConfig getSessionCookieConfig()
Description copied from interface: javax.servlet.ServletContext
Gets the SessionCookieConfig object through which various properties of the session tracking cookies created on behalf of this ServletContext may be configured.

Repeated invocations of this method will return the same SessionCookieConfig instance.

Specified by:
getSessionCookieConfig in interface javax.servlet.ServletContext
Returns:
the SessionCookieConfig object through which various properties of the session tracking cookies created on behalf of this ServletContext may be configured

createFilter

public <T extends javax.servlet.Filter> T createFilter(java.lang.Class<T> c)
                                            throws javax.servlet.ServletException
Description copied from interface: javax.servlet.ServletContext
Instantiates the given Filter class.

The returned Filter instance may be further customized before it is registered with this ServletContext via a call to ServletContext.addFilter(String,Filter).

The given Filter class must define a zero argument constructor, which is used to instantiate it.

This method supports resource injection if the given clazz represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
createFilter in interface javax.servlet.ServletContext
Parameters:
c - the Filter class to instantiate
Returns:
the new Filter instance
Throws:
javax.servlet.ServletException - if the given clazz fails to be instantiated

createServlet

public <T extends javax.servlet.Servlet> T createServlet(java.lang.Class<T> c)
                                              throws javax.servlet.ServletException
Description copied from interface: javax.servlet.ServletContext
Instantiates the given Servlet class.

The returned Servlet instance may be further customized before it is registered with this ServletContext via a call to ServletContext.addServlet(String,Servlet).

The given Servlet class must define a zero argument constructor, which is used to instantiate it.

This method introspects the given clazz for the following annotations: ServletSecurity, MultipartConfig, javax.annotation.security.RunAs, and javax.annotation.security.DeclareRoles. In addition, this method supports resource injection if the given clazz represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
createServlet in interface javax.servlet.ServletContext
Parameters:
c - the Servlet class to instantiate
Returns:
the new Servlet instance
Throws:
javax.servlet.ServletException - if the given clazz fails to be instantiated

setInitParameter

public boolean setInitParameter(java.lang.String name,
                                java.lang.String value)
Description copied from interface: javax.servlet.ServletContext
Sets the context initialization parameter with the given name and value on this ServletContext.

Specified by:
setInitParameter in interface javax.servlet.ServletContext
Parameters:
name - the name of the context initialization parameter to set
value - the value of the context initialization parameter to set
Returns:
true if the context initialization parameter with the given name and value was set successfully on this ServletContext, and false if it was not set because this ServletContext already contains a context initialization parameter with a matching name

setSessionTrackingModes

public void setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
Description copied from interface: javax.servlet.ServletContext
Sets the session tracking modes that are to become effective for this ServletContext.

The given sessionTrackingModes replaces any session tracking modes set by a previous invocation of this method on this ServletContext.

Specified by:
setSessionTrackingModes in interface javax.servlet.ServletContext
Parameters:
sessionTrackingModes - the set of session tracking modes to become effective for this ServletContext

addListener

public void addListener(java.lang.String className)
Description copied from interface: javax.servlet.ServletContext
Adds the listener with the given class name to this ServletContext.

The class with the given name will be loaded using the classloader associated with the application represented by this ServletContext, and must implement one or more of the following interfaces:

If this ServletContext was passed to ServletContainerInitializer.onStartup(java.util.Set>, javax.servlet.ServletContext), then the class with the given name may also implement ServletContextListener, in addition to the interfaces listed above.

As part of this method call, the container must load the class with the specified class name to ensure that it implements one of the required interfaces.

If the class with the given name implements a listener interface whose invocation order corresponds to the declaration order (i.e., if it implements ServletRequestListener, ServletContextListener, or HttpSessionListener), then the new listener will be added to the end of the ordered list of listeners of that interface.

This method supports resource injection if the class with the given className represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
addListener in interface javax.servlet.ServletContext
Parameters:
className - the fully qualified class name of the listener

addListener

public <T extends java.util.EventListener> void addListener(T listener)
Description copied from interface: javax.servlet.ServletContext
Adds the given listener to this ServletContext.

The given listener must be an instance of one or more of the following interfaces:

If this ServletContext was passed to ServletContainerInitializer.onStartup(java.util.Set>, javax.servlet.ServletContext), then the given listener may also be an instance of ServletContextListener, in addition to the interfaces listed above.

If the given listener is an instance of a listener interface whose invocation order corresponds to the declaration order (i.e., if it is an instance of ServletRequestListener, ServletContextListener, or HttpSessionListener), then the listener will be added to the end of the ordered list of listeners of that interface.

Specified by:
addListener in interface javax.servlet.ServletContext
Parameters:
listener - the listener to be added

addListener

public void addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)
Description copied from interface: javax.servlet.ServletContext
Adds a listener of the given class type to this ServletContext.

The given listenerClass must implement one or more of the following interfaces:

If this ServletContext was passed to ServletContainerInitializer.onStartup(java.util.Set>, javax.servlet.ServletContext), then the given listenerClass may also implement ServletContextListener, in addition to the interfaces listed above.

If the given listenerClass implements a listener interface whose invocation order corresponds to the declaration order (i.e., if it implements ServletRequestListener, ServletContextListener, or HttpSessionListener), then the new listener will be added to the end of the ordered list of listeners of that interface.

This method supports resource injection if the given listenerClass represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
addListener in interface javax.servlet.ServletContext
Parameters:
listenerClass - the listener class to be instantiated

createListener

public <T extends java.util.EventListener> T createListener(java.lang.Class<T> clazz)
                                                 throws javax.servlet.ServletException
Description copied from interface: javax.servlet.ServletContext
Instantiates the given EventListener class.

The specified EventListener class must implement at least one of the ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, HttpSessionListener, or HttpSessionAttributeListener interfaces.

The returned EventListener instance may be further customized before it is registered with this ServletContext via a call to ServletContext.addListener(EventListener).

The given EventListener class must define a zero argument constructor, which is used to instantiate it.

This method supports resource injection if the given clazz represents a Managed Bean. See the Java EE platform and JSR 299 specifications for additional details about Managed Beans and resource injection.

Specified by:
createListener in interface javax.servlet.ServletContext
Parameters:
clazz - the EventListener class to instantiate
Returns:
the new EventListener instance
Throws:
javax.servlet.ServletException - if the given clazz fails to be instantiated

getClassLoader

public java.lang.ClassLoader getClassLoader()
Description copied from interface: javax.servlet.ServletContext
Gets the class loader of the web application represented by this ServletContext.

If a security manager exists, and the caller's class loader is not the same as, or an ancestor of the requested class loader, then the security manager's checkPermission method is called with a RuntimePermission("getClassLoader") permission to check whether access to the requested class loader should be granted.

Specified by:
getClassLoader in interface javax.servlet.ServletContext
Returns:
the class loader of the web application represented by this ServletContext

getJspConfigDescriptor

public javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
Description copied from interface: javax.servlet.ServletContext
Gets the <jsp-config> related configuration that was aggregated from the web.xml and web-fragment.xml descriptor files of the web application represented by this ServletContext.

Specified by:
getJspConfigDescriptor in interface javax.servlet.ServletContext
Returns:
the <jsp-config> related configuration that was aggregated from the web.xml and web-fragment.xml descriptor files of the web application represented by this ServletContext, or null if no such configuration exists
See Also:
JspConfigDescriptor

getEffectiveMajorVersion

public int getEffectiveMajorVersion()
Description copied from interface: javax.servlet.ServletContext
Gets the major version of the Servlet specification that the application represented by this ServletContext is based on.

The value returned may be different from ServletContext.getMajorVersion(), which returns the major version of the Servlet specification supported by the Servlet container.

Specified by:
getEffectiveMajorVersion in interface javax.servlet.ServletContext
Returns:
the major version of the Servlet specification that the application represented by this ServletContext is based on

getEffectiveMinorVersion

public int getEffectiveMinorVersion()
Description copied from interface: javax.servlet.ServletContext
Gets the minor version of the Servlet specification that the application represented by this ServletContext is based on.

The value returned may be different from ServletContext.getMinorVersion(), which returns the minor version of the Servlet specification supported by the Servlet container.

Specified by:
getEffectiveMinorVersion in interface javax.servlet.ServletContext
Returns:
the minor version of the Servlet specification that the application xrepresented by this ServletContext is based on

declareRoles

public void declareRoles(java.lang.String... roleNames)
Description copied from interface: javax.servlet.ServletContext
Declares role names that are tested using isUserInRole.

Roles that are implicitly declared as a result of their use within the setServletSecurity or setRunAsRole methods of the ServletRegistration interface need not be declared.

Specified by:
declareRoles in interface javax.servlet.ServletContext
Parameters:
roleNames - the role names being declared

checkListenerType

protected void checkListenerType(java.util.EventListener listener)

getContext

protected StandardContext getContext()

getReadonlyAttributes

protected java.util.Map getReadonlyAttributes()

clearAttributes

protected void clearAttributes()
Clear all application-created attributes.


getFacade

protected javax.servlet.ServletContext getFacade()
Return the facade associated with this ApplicationContext.



Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.