com.caucho.server.webapp
Class ServletContextImpl

java.lang.Object
  extended by com.caucho.server.webapp.ServletContextCompat
      extended by com.caucho.server.webapp.ServletContextImpl
All Implemented Interfaces:
ServletContext
Direct Known Subclasses:
WebApp

public class ServletContextImpl
extends ServletContextCompat
implements ServletContext

Bare-bones servlet context implementation.


Field Summary
 
Fields inherited from interface javax.servlet.ServletContext
ORDERED_LIBS, TEMPDIR
 
Constructor Summary
ServletContextImpl()
           
 
Method Summary
protected  void addAttributeListener(ServletContextAttributeListener listener)
          Adds the listener.
 FilterRegistration.Dynamic addFilter(java.lang.String filterName, java.lang.Class<? extends Filter> filterClass)
          Adds a filter using filterClass
 FilterRegistration.Dynamic addFilter(java.lang.String filterName, Filter filter)
          Adds a dynamic filter registration using filter
 FilterRegistration.Dynamic addFilter(java.lang.String filterName, java.lang.String className)
          Adds a dynamic filter registration using className
 void addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)
           
 void addListener(ListenerConfig config)
           
 void addListener(java.lang.String className)
           
<T extends java.util.EventListener>
void
addListener(T t)
           
 ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.Class<? extends Servlet> servletClass)
          Adds a servlet class to the servlet container.
 ServletRegistration.Dynamic addServlet(java.lang.String servletName, Servlet servlet)
          Adds a servlet to context
 ServletRegistration.Dynamic addServlet(java.lang.String servletName, java.lang.String className)
          Adds a servlet with the given className to context
<T extends Filter>
T
createFilter(java.lang.Class<T> c)
          Create a filter using class
<T extends java.util.EventListener>
T
createListener(java.lang.Class<T> listenerClass)
           
<T extends Servlet>
T
createServlet(java.lang.Class<T> c)
          Creates a servlet instance using the web-apps injection.
 void declareRoles(java.lang.String... roleNames)
           
 java.lang.Object getAttribute(java.lang.String name)
          Returns the named attribute.
 java.util.Enumeration<java.lang.String> getAttributeNames()
          Returns an enumeration of the attribute names.
 Path getCauchoPath(java.lang.String name)
           
 java.lang.ClassLoader getClassLoader()
           
 ServletContext getContext(java.lang.String uri)
          Returns the servlet context for the name.
 java.lang.String getContextPath()
          Gets the servlet context name
 int getEffectiveMajorVersion()
           
 int getEffectiveMinorVersion()
           
 FilterRegistration getFilterRegistration(java.lang.String filterName)
          Returns filter registration sing filterName
 java.util.Map<java.lang.String,? extends FilterRegistration> getFilterRegistrations()
          Returns filter registrations
 java.lang.String getInitParameter(java.lang.String name)
          Gets the init params
 java.util.Enumeration<java.lang.String> getInitParameterNames()
          Gets the init params
 JspConfigDescriptor getJspConfigDescriptor()
           
 int getMajorVersion()
          Returns the servlet major version
 java.lang.String getMimeType(java.lang.String uri)
          Returns the mime type for the name.
 int getMinorVersion()
          Returns the servlet minor version
 RequestDispatcher getNamedDispatcher(java.lang.String servletName)
          Returns a dispatcher for the named servlet.
 java.lang.String getRealPath(java.lang.String uri)
          Maps from a URI to a real path.
 RequestDispatcher getRequestDispatcher(java.lang.String uri)
          Returns the dispatcher.
 java.net.URL getResource(java.lang.String name)
          Returns a resource for the given uri.
 java.net.URLConnection getResource(java.net.URL url)
           
 java.io.InputStream getResourceAsStream(java.lang.String uripath)
          Returns the resource for a uripath as an input stream.
 java.util.Set<java.lang.String> getResourcePaths(java.lang.String prefix)
          Returns an enumeration of all the resources.
 Path getRootDirectory()
           
 java.lang.String getServerInfo()
          Returns the server information
 Servlet getServlet(java.lang.String name)
           
 java.lang.String getServletContextName()
          Gets the servlet context name
 java.util.Enumeration<java.lang.String> getServletNames()
           
 ServletRegistration getServletRegistration(java.lang.String servletName)
          Returs servlet registration using servletName
 java.util.Map<java.lang.String,ServletRegistration> getServletRegistrations()
          Returns servlet registrations
 java.util.Enumeration<Servlet> getServlets()
           
protected  boolean isActive()
           
 void log(java.lang.Exception e, java.lang.String msg)
          Deprecated.  
 void log(java.lang.String message)
          Logs a message to the error file.
 void log(java.lang.String message, java.lang.Throwable e)
          Error logging
 void removeAttribute(java.lang.String name)
          Removes an attribute from the servlet context.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets an application attribute.
 void setDisplayName(java.lang.String name)
          Sets the servlet context name
protected  void setInitParam(java.lang.String name, java.lang.String value)
          Sets an init param
 boolean setInitParameter(java.lang.String name, java.lang.String value)
          Sets an init param
 void setSessionTrackingModes(java.util.Set<SessionTrackingMode> modes)
          The session tracking mode
 
Methods inherited from class com.caucho.server.webapp.ServletContextCompat
getDefaultSessionTrackingModes, getEffectiveSessionTrackingModes, getSessionCookieConfig, setSessionTrackingModes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletContext
getDefaultSessionTrackingModes, getEffectiveSessionTrackingModes, getSessionCookieConfig
 

Constructor Detail

ServletContextImpl

public ServletContextImpl()
Method Detail

getRootDirectory

public Path getRootDirectory()

setDisplayName

public void setDisplayName(java.lang.String name)
Sets the servlet context name


getServletContextName

public java.lang.String getServletContextName()
Gets the servlet context name

Specified by:
getServletContextName in interface ServletContext

getContextPath

public java.lang.String getContextPath()
Gets the servlet context name

Specified by:
getContextPath in interface ServletContext

addAttributeListener

protected void addAttributeListener(ServletContextAttributeListener listener)
Adds the listener.


getServerInfo

public java.lang.String getServerInfo()
Returns the server information

Specified by:
getServerInfo in interface ServletContext

getMajorVersion

public int getMajorVersion()
Returns the servlet major version

Specified by:
getMajorVersion in interface ServletContext

getEffectiveMajorVersion

public int getEffectiveMajorVersion()
Specified by:
getEffectiveMajorVersion in interface ServletContext
Returns:
major version of the spec the app is based on

getMinorVersion

public int getMinorVersion()
Returns the servlet minor version

Specified by:
getMinorVersion in interface ServletContext

getEffectiveMinorVersion

public int getEffectiveMinorVersion()
Specified by:
getEffectiveMinorVersion in interface ServletContext
Returns:
minor version of the spec the app is based on

setInitParameter

public boolean setInitParameter(java.lang.String name,
                                java.lang.String value)
Sets an init param

Specified by:
setInitParameter in interface ServletContext
Returns:

setInitParam

protected void setInitParam(java.lang.String name,
                            java.lang.String value)
Sets an init param


getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Gets the init params

Specified by:
getInitParameter in interface ServletContext
Parameters:
name - init parameter name
Returns:
init parameter value

getInitParameterNames

public java.util.Enumeration<java.lang.String> getInitParameterNames()
Gets the init params

Specified by:
getInitParameterNames in interface ServletContext

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the named attribute.

Specified by:
getAttribute in interface ServletContext
Parameters:
name - of the attribute.
Returns:
stored value

getAttributeNames

public java.util.Enumeration<java.lang.String> getAttributeNames()
Returns an enumeration of the attribute names.

Specified by:
getAttributeNames in interface ServletContext

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets an application attribute.

Specified by:
setAttribute in interface ServletContext
Parameters:
name - the name of the attribute
value - the value of the attribute

removeAttribute

public void removeAttribute(java.lang.String name)
Removes an attribute from the servlet context.

Specified by:
removeAttribute in interface ServletContext
Parameters:
name - the name of the attribute to remove.

getRealPath

public java.lang.String getRealPath(java.lang.String uri)
Maps from a URI to a real path.

Specified by:
getRealPath in interface ServletContext
Parameters:
uri - path relative to the application root to be translated.
Returns:
native file path for the uri.

getResource

public java.net.URL getResource(java.lang.String name)
                         throws java.net.MalformedURLException
Returns a resource for the given uri.

XXX: jdk 1.1.x doesn't appear to allow creation of private URL streams.

Specified by:
getResource in interface ServletContext
Parameters:
name - path relative to the application root.
Throws:
java.net.MalformedURLException

getResource

public java.net.URLConnection getResource(java.net.URL url)
                                   throws java.io.IOException
Throws:
java.io.IOException

getCauchoPath

public Path getCauchoPath(java.lang.String name)

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String uripath)
Returns the resource for a uripath as an input stream.

Specified by:
getResourceAsStream in interface ServletContext
Parameters:
uripath - path relative to the application root.
Returns:
InputStream to the resource.

getResourcePaths

public java.util.Set<java.lang.String> getResourcePaths(java.lang.String prefix)
Returns an enumeration of all the resources.

Specified by:
getResourcePaths in interface ServletContext

getContext

public ServletContext getContext(java.lang.String uri)
Returns the servlet context for the name.

Specified by:
getContext in interface ServletContext
Parameters:
uri - path relative to the root
Returns:
the ServletContext responsible for the given uri.

getMimeType

public java.lang.String getMimeType(java.lang.String uri)
Returns the mime type for the name.

Specified by:
getMimeType in interface ServletContext
Parameters:
uri - path relative to the application root.

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(java.lang.String uri)
Returns the dispatcher.

Specified by:
getRequestDispatcher in interface ServletContext
Parameters:
uri - path relative to the app root (including query string) for the included file.
Returns:
RequestDispatcher for later inclusion or forwarding.

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(java.lang.String servletName)
Returns a dispatcher for the named servlet.

Specified by:
getNamedDispatcher in interface ServletContext
Parameters:
servletName - the servlet name to include or forward to.
Returns:
RequestDispatcher for later inclusion or forwarding.

log

public final void log(java.lang.String message)
Logs a message to the error file.

Specified by:
log in interface ServletContext
Parameters:
msg - the message to log

log

public final void log(java.lang.Exception e,
                      java.lang.String msg)
Deprecated. 

Specified by:
log in interface ServletContext

log

public void log(java.lang.String message,
                java.lang.Throwable e)
Error logging

Specified by:
log in interface ServletContext
Parameters:
message - message to log
e - stack trace of the error

getServlet

public Servlet getServlet(java.lang.String name)
Specified by:
getServlet in interface ServletContext

getServletNames

public java.util.Enumeration<java.lang.String> getServletNames()
Specified by:
getServletNames in interface ServletContext

getServlets

public java.util.Enumeration<Servlet> getServlets()
Specified by:
getServlets in interface ServletContext

setSessionTrackingModes

public void setSessionTrackingModes(java.util.Set<SessionTrackingMode> modes)
Description copied from interface: ServletContext
The session tracking mode

Specified by:
setSessionTrackingModes in interface ServletContext

addServlet

public ServletRegistration.Dynamic addServlet(java.lang.String servletName,
                                              java.lang.String className)
Description copied from interface: ServletContext
Adds a servlet with the given className to context

Specified by:
addServlet in interface ServletContext

addServlet

public ServletRegistration.Dynamic addServlet(java.lang.String servletName,
                                              Servlet servlet)
Description copied from interface: ServletContext
Adds a servlet to context

Specified by:
addServlet in interface ServletContext

addServlet

public ServletRegistration.Dynamic addServlet(java.lang.String servletName,
                                              java.lang.Class<? extends Servlet> servletClass)
Description copied from interface: ServletContext
Adds a servlet class to the servlet container.

Specified by:
addServlet in interface ServletContext

createServlet

public <T extends Servlet> T createServlet(java.lang.Class<T> c)
                                throws ServletException
Description copied from interface: ServletContext
Creates a servlet instance using the web-apps injection.

Specified by:
createServlet in interface ServletContext
Throws:
ServletException

getServletRegistration

public ServletRegistration getServletRegistration(java.lang.String servletName)
Description copied from interface: ServletContext
Returs servlet registration using servletName

Specified by:
getServletRegistration in interface ServletContext
Returns:
a ServletRegistration object

getServletRegistrations

public java.util.Map<java.lang.String,ServletRegistration> getServletRegistrations()
Description copied from interface: ServletContext
Returns servlet registrations

Specified by:
getServletRegistrations in interface ServletContext
Returns:

addFilter

public FilterRegistration.Dynamic addFilter(java.lang.String filterName,
                                            java.lang.String className)
Description copied from interface: ServletContext
Adds a dynamic filter registration using className

Specified by:
addFilter in interface ServletContext
Returns:

addFilter

public FilterRegistration.Dynamic addFilter(java.lang.String filterName,
                                            Filter filter)
Description copied from interface: ServletContext
Adds a dynamic filter registration using filter

Specified by:
addFilter in interface ServletContext
Returns:

addFilter

public FilterRegistration.Dynamic addFilter(java.lang.String filterName,
                                            java.lang.Class<? extends Filter> filterClass)
Description copied from interface: ServletContext
Adds a filter using filterClass

Specified by:
addFilter in interface ServletContext
Returns:

createFilter

public <T extends Filter> T createFilter(java.lang.Class<T> c)
                              throws ServletException
Description copied from interface: ServletContext
Create a filter using class

Specified by:
createFilter in interface ServletContext
Returns:
Throws:
ServletException

getFilterRegistration

public FilterRegistration getFilterRegistration(java.lang.String filterName)
Description copied from interface: ServletContext
Returns filter registration sing filterName

Specified by:
getFilterRegistration in interface ServletContext
Returns:

getFilterRegistrations

public java.util.Map<java.lang.String,? extends FilterRegistration> getFilterRegistrations()
Returns filter registrations

Specified by:
getFilterRegistrations in interface ServletContext
Returns:

addListener

@Configurable
public void addListener(ListenerConfig config)
                 throws java.lang.Exception
Throws:
java.lang.Exception

addListener

public void addListener(java.lang.String className)
Specified by:
addListener in interface ServletContext

addListener

public <T extends java.util.EventListener> void addListener(T t)
Specified by:
addListener in interface ServletContext

addListener

public void addListener(java.lang.Class<? extends java.util.EventListener> listenerClass)
Specified by:
addListener in interface ServletContext

getJspConfigDescriptor

public JspConfigDescriptor getJspConfigDescriptor()
Specified by:
getJspConfigDescriptor in interface ServletContext

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in interface ServletContext

declareRoles

public void declareRoles(java.lang.String... roleNames)
Specified by:
declareRoles in interface ServletContext

isActive

protected boolean isActive()

createListener

public <T extends java.util.EventListener> T createListener(java.lang.Class<T> listenerClass)
                                                 throws ServletException
Specified by:
createListener in interface ServletContext
Throws:
ServletException