Class ServletWebContext
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap
-
- org.apache.commons.chain.impl.ContextBase
-
- org.apache.commons.chain.web.WebContext
-
- 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
WebContextsuitable 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: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
- Author:
- Craig R. McClanahan
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.MapapplicationScopeThe lazily instantiatedMapof application scope attributes.protected javax.servlet.ServletContextcontextTheServletContextfor this web application.private java.util.MapcookieValuesThe lazily instantiatedMapof cookies.private java.util.MapheaderThe lazily instantiatedMapof header name-value combinations (immutable).private java.util.MapheaderValuesThe lazily instantitatedMapof header name-values combinations (immutable).private java.util.MapinitParamThe lazily instantiatedMapof context initialization parameters.private java.util.MapparamThe lazily instantiatedMapof request parameter name-value.private java.util.MapparamValuesThe lazily instantiatedMapof request parameter name-values.protected javax.servlet.http.HttpServletRequestrequestTheHttpServletRequestfor this request.private java.util.MaprequestScopeThe lazily instantiatedMapof request scope attributes.protected javax.servlet.http.HttpServletResponseresponseTheHttpServletResponsefor this request.private java.util.MapsessionScopeThe lazily instantiatedMapof session scope attributes.
-
Constructor Summary
Constructors Constructor Description ServletWebContext()Construct an uninitializedServletWebContextinstance.ServletWebContext(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Construct aServletWebContextinstance that is initialized with the specified Servlet API objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.MapgetApplicationScope()See theWebContext's Javadoc.javax.servlet.ServletContextgetContext()Return theServletContextfor this context.java.util.MapgetCookies()See theWebContext's Javadoc.java.util.MapgetHeader()See theWebContext's Javadoc.java.util.MapgetHeaderValues()See theWebContext's Javadoc.java.util.MapgetInitParam()See theWebContext's Javadoc.java.util.MapgetParam()See theWebContext's Javadoc.java.util.MapgetParamValues()See theWebContext's Javadoc.javax.servlet.http.HttpServletRequestgetRequest()Return theHttpServletRequestfor this context.java.util.MapgetRequestScope()See theWebContext's Javadoc.javax.servlet.http.HttpServletResponsegetResponse()Return theHttpServletResponsefor this context.java.util.MapgetSessionScope()See theWebContext's Javadoc.voidinitialize(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Initialize (or reinitialize) thisServletWebContextinstance for the specified Servlet API objects.voidrelease()Release references to allocated resources acquired ininitialize()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, compute, computeIfAbsent, computeIfPresent, containsKey, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
-
-
-
Field Detail
-
applicationScope
private java.util.Map applicationScope
The lazily instantiated
Mapof application scope attributes.
-
context
protected javax.servlet.ServletContext context
The
ServletContextfor this web application.
-
header
private java.util.Map header
The lazily instantiated
Mapof header name-value combinations (immutable).
-
headerValues
private java.util.Map headerValues
The lazily instantitated
Mapof header name-values combinations (immutable).
-
initParam
private java.util.Map initParam
The lazily instantiated
Mapof context initialization parameters.
-
cookieValues
private java.util.Map cookieValues
The lazily instantiated
Mapof cookies.
-
param
private java.util.Map param
The lazily instantiated
Mapof request parameter name-value.
-
paramValues
private java.util.Map paramValues
The lazily instantiated
Mapof request parameter name-values.
-
request
protected javax.servlet.http.HttpServletRequest request
The
HttpServletRequestfor this request.
-
requestScope
private java.util.Map requestScope
The lazily instantiated
Mapof request scope attributes.
-
response
protected javax.servlet.http.HttpServletResponse response
The
HttpServletResponsefor this request.
-
sessionScope
private java.util.Map sessionScope
The lazily instantiated
Mapof session scope attributes.
-
-
Constructor Detail
-
ServletWebContext
public ServletWebContext()
Construct an uninitialized
ServletWebContextinstance.
-
ServletWebContext
public ServletWebContext(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Construct a
ServletWebContextinstance that is initialized with the specified Servlet API objects.- Parameters:
context- TheServletContextfor this web applicationrequest- TheHttpServletRequestfor this requestresponse- TheHttpServletResponsefor this request
-
-
Method Detail
-
getContext
public javax.servlet.ServletContext getContext()
Return the
ServletContextfor this context.- Returns:
- The
ServletContextfor this context.
-
getRequest
public javax.servlet.http.HttpServletRequest getRequest()
Return the
HttpServletRequestfor this context.- Returns:
- The
HttpServletRequestfor this context.
-
getResponse
public javax.servlet.http.HttpServletResponse getResponse()
Return the
HttpServletResponsefor this context.- Returns:
- The
HttpServletResponsefor this context.
-
initialize
public void initialize(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Initialize (or reinitialize) this
ServletWebContextinstance for the specified Servlet API objects.- Parameters:
context- TheServletContextfor this web applicationrequest- TheHttpServletRequestfor this requestresponse- TheHttpServletResponsefor 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 thaninitialize()will return undefined results.
-
getApplicationScope
public java.util.Map getApplicationScope()
See theWebContext's Javadoc.- Specified by:
getApplicationScopein classWebContext- Returns:
- Application scope Map.
-
getHeader
public java.util.Map getHeader()
See theWebContext's Javadoc.- Specified by:
getHeaderin classWebContext- Returns:
- Header values Map.
-
getHeaderValues
public java.util.Map getHeaderValues()
See theWebContext's Javadoc.- Specified by:
getHeaderValuesin classWebContext- Returns:
- Header values Map.
-
getInitParam
public java.util.Map getInitParam()
See theWebContext's Javadoc.- Specified by:
getInitParamin classWebContext- Returns:
- Initialization parameter Map.
-
getParam
public java.util.Map getParam()
See theWebContext's Javadoc.- Specified by:
getParamin classWebContext- Returns:
- Request parameter Map.
-
getParamValues
public java.util.Map getParamValues()
See theWebContext's Javadoc.- Specified by:
getParamValuesin classWebContext- Returns:
- Request parameter Map.
-
getCookies
public java.util.Map getCookies()
See theWebContext's Javadoc.- Specified by:
getCookiesin classWebContext- Returns:
- Map of Cookies.
- Since:
- Chain 1.1
-
getRequestScope
public java.util.Map getRequestScope()
See theWebContext's Javadoc.- Specified by:
getRequestScopein classWebContext- Returns:
- Request scope Map.
-
getSessionScope
public java.util.Map getSessionScope()
See theWebContext's Javadoc.- Specified by:
getSessionScopein classWebContext- Returns:
- Session scope Map.
-
-