com.caucho.server.webapp
Class ServletContextImpl

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

public class ServletContextImpl
extends java.lang.Object
implements ServletContext

Bare-bones servlet context implementation.


Constructor Summary
ServletContextImpl()
           
 
Method Summary
protected  void addAttributeListener(ServletContextAttributeListener listener)
          Adds the listener.
 Path getAppDir()
           
 java.lang.Object getAttribute(java.lang.String name)
          Returns the named attribute.
 java.util.Enumeration getAttributeNames()
          Returns an enumeration of the attribute names.
 ServletContext getContext(java.lang.String uri)
          Returns the servlet context for the name.
 java.lang.String getContextPath()
          Gets the servlet context name
 java.lang.String getInitParameter(java.lang.String name)
          Gets the init params
 java.util.Enumeration getInitParameterNames()
          Gets the init params
 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.io.InputStream getResourceAsStream(java.lang.String uripath)
          Returns the resource for a uripath as an input stream.
 java.util.Set getResourcePaths(java.lang.String prefix)
          Returns an enumeration of all the resources.
 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 getServletNames()
           
 java.util.Enumeration getServlets()
           
 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 setInitParameter(java.lang.String name, java.lang.String value)
          Sets an init param
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletContextImpl

public ServletContextImpl()
Method Detail

getAppDir

public Path getAppDir()

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

getMinorVersion

public int getMinorVersion()
Returns the servlet minor version

Specified by:
getMinorVersion in interface ServletContext

setInitParameter

protected void setInitParameter(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 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 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

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
Returns:
InputStream to the resource.

getResourcePaths

public java.util.Set 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 getServletNames()
Specified by:
getServletNames in interface ServletContext

getServlets

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