org.apache.commons.chain.web.servlet
Class ServletWebContext

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by org.apache.commons.chain.impl.ContextBase
              extended by org.apache.commons.chain.web.WebContext
                  extended by org.apache.commons.chain.web.servlet.ServletWebContext
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map, Context

public class ServletWebContext
extends WebContext

Concrete implementation of WebContext suitable for use in Servlets and JSP pages. The abstract methods are mapped to the appropriate collections of the underlying servlet context, request, and response instances that are passed to the constructor (or the initialize method).

Version:
$Revision: 1.5 $ $Date: 2004/02/25 00:01:04 $
Author:
Craig R. McClanahan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
private  java.util.Map applicationScope
          The lazily instantiated Map of application scope attributes.
protected  javax.servlet.ServletContext context
          The ServletContext for this web application.
private  java.util.Map header
          The lazily instantiated Map of header name-value combinations (immutable).
private  java.util.Map headerValues
          The lazily instantitated Map of header name-values combinations (immutable).
private  java.util.Map initParam
          The lazily instantiated Map of context initialization parameters.
private  java.util.Map param
          The lazily instantiated Map of request parameter name-value.
private  java.util.Map paramValues
          The lazily instantiated Map of request parameter name-values.
protected  javax.servlet.http.HttpServletRequest request
          The HttpServletRequest for this request.
private  java.util.Map requestScope
          The lazily instantiated Map of request scope attributes.
protected  javax.servlet.http.HttpServletResponse response
          The HttpServletResponse for this request.
private  java.util.Map sessionScope
          The lazily instantiated Map of session scope attributes.
 
Constructor Summary
ServletWebContext()
          Construct an uninitialized ServletWebContext instance.
ServletWebContext(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Construct a ServletWebContext instance that is initialized with the specified Servlet API objects.
 
Method Summary
 java.util.Map getApplicationScope()
          Return a mutable Map that maps application scope attribute names to their values.
 javax.servlet.ServletContext getContext()
          Return the ServletContext for this context.
 java.util.Map getHeader()
          Return an immutable Map that maps header names to the first (or only) header value (as a String).
 java.util.Map getHeaderValues()
          Return an immutable Map that maps header names to the set of all values specified in the request (as a String array).
 java.util.Map getInitParam()
          Return an immutable Map that maps context application initialization parameters to their values.
 java.util.Map getParam()
          Return an immutable Map that maps request parameter names to the first (or only) value (as a String).
 java.util.Map getParamValues()
          Return an immutable Map that maps request parameter names to the set of all values (as a String array).
 javax.servlet.http.HttpServletRequest getRequest()
          Return the HttpServletRequest for this context.
 java.util.Map getRequestScope()
          Return a mutable Map that maps request scope attribute names to their values.
 javax.servlet.http.HttpServletResponse getResponse()
          Return the HttpServletResponse for this context.
 java.util.Map getSessionScope()
          Return a mutable Map that maps session scope attribute names to their values.
 void initialize(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Initialize (or reinitialize) this ServletWebContext instance for the specified Servlet API objects.
 void release()
          Release references to allocated resources acquired in initialize() of via subsequent processing.
 
Methods inherited from class org.apache.commons.chain.impl.ContextBase
clear, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, values
 
Methods inherited from class java.util.HashMap
clone, containsKey, size
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, equals, hashCode, size
 

Field Detail

applicationScope

private java.util.Map applicationScope

The lazily instantiated Map of application scope attributes.


context

protected javax.servlet.ServletContext context

The ServletContext for this web application.


header

private java.util.Map header

The lazily instantiated Map of header name-value combinations (immutable).


headerValues

private java.util.Map headerValues

The lazily instantitated Map of header name-values combinations (immutable).


initParam

private java.util.Map initParam

The lazily instantiated Map of context initialization parameters.


param

private java.util.Map param

The lazily instantiated Map of request parameter name-value.


paramValues

private java.util.Map paramValues

The lazily instantiated Map of request parameter name-values.


request

protected javax.servlet.http.HttpServletRequest request

The HttpServletRequest for this request.


requestScope

private java.util.Map requestScope

The lazily instantiated Map of request scope attributes.


response

protected javax.servlet.http.HttpServletResponse response

The HttpServletResponse for this request.


sessionScope

private java.util.Map sessionScope

The lazily instantiated Map of session scope attributes.

Constructor Detail

ServletWebContext

public ServletWebContext()

Construct an uninitialized ServletWebContext instance.


ServletWebContext

public ServletWebContext(javax.servlet.ServletContext context,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)

Construct a ServletWebContext instance that is initialized with the specified Servlet API objects.

Parameters:
context - The ServletContext for this web application
request - The HttpServletRequest for this request
response - The HttpServletResponse for this request
Method Detail

getContext

public javax.servlet.ServletContext getContext()

Return the ServletContext for this context.


getRequest

public javax.servlet.http.HttpServletRequest getRequest()

Return the HttpServletRequest for this context.


getResponse

public javax.servlet.http.HttpServletResponse getResponse()

Return the HttpServletResponse for this context.


initialize

public void initialize(javax.servlet.ServletContext context,
                       javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response)

Initialize (or reinitialize) this ServletWebContext instance for the specified Servlet API objects.

Parameters:
context - The ServletContext for this web application
request - The HttpServletRequest for this request
response - The HttpServletResponse for this request

release

public void release()

Release references to allocated resources acquired in initialize() of via subsequent processing. After this method is called, subsequent calls to any other method than initialize() will return undefined results.


getApplicationScope

public java.util.Map getApplicationScope()
Description copied from class: WebContext

Return a mutable Map that maps application scope attribute names to their values.

Specified by:
getApplicationScope in class WebContext

getHeader

public java.util.Map getHeader()
Description copied from class: WebContext

Return an immutable Map that maps header names to the first (or only) header value (as a String). Header names must be matched in a case-insensitive manner.

Specified by:
getHeader in class WebContext

getHeaderValues

public java.util.Map getHeaderValues()
Description copied from class: WebContext

Return an immutable Map that maps header names to the set of all values specified in the request (as a String array). Header names must be matched in a case-insensitive manner.

Specified by:
getHeaderValues in class WebContext

getInitParam

public java.util.Map getInitParam()
Description copied from class: WebContext

Return an immutable Map that maps context application initialization parameters to their values.

Specified by:
getInitParam in class WebContext

getParam

public java.util.Map getParam()
Description copied from class: WebContext

Return an immutable Map that maps request parameter names to the first (or only) value (as a String).

Specified by:
getParam in class WebContext

getParamValues

public java.util.Map getParamValues()
Description copied from class: WebContext

Return an immutable Map that maps request parameter names to the set of all values (as a String array).

Specified by:
getParamValues in class WebContext

getRequestScope

public java.util.Map getRequestScope()
Description copied from class: WebContext

Return a mutable Map that maps request scope attribute names to their values.

Specified by:
getRequestScope in class WebContext

getSessionScope

public java.util.Map getSessionScope()
Description copied from class: WebContext

Return a mutable Map that maps session scope attribute names to their values.

Specified by:
getSessionScope in class WebContext