You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/07/19 13:42:55 UTC
svn commit: r1363305 [3/3] - in /commons/proper/chain/trunk:
apps/cookbook-examples/src/main/java/org/apache/commons/chain2/cookbook/agility/
apps/cookbook-examples/src/main/java/org/apache/commons/chain2/cookbook/agility/impl/
apps/cookbook-examples/s...
Modified: commons/proper/chain/trunk/web/src/main/java/org/apache/commons/chain2/web/servlet/ServletWebContext.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/web/src/main/java/org/apache/commons/chain2/web/servlet/ServletWebContext.java?rev=1363305&r1=1363304&r2=1363305&view=diff
==============================================================================
--- commons/proper/chain/trunk/web/src/main/java/org/apache/commons/chain2/web/servlet/ServletWebContext.java (original)
+++ commons/proper/chain/trunk/web/src/main/java/org/apache/commons/chain2/web/servlet/ServletWebContext.java Thu Jul 19 11:42:53 2012
@@ -16,7 +16,6 @@
*/
package org.apache.commons.chain2.web.servlet;
-
import org.apache.commons.chain2.web.WebContext;
import javax.servlet.ServletContext;
@@ -25,7 +24,6 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
-
/**
* <p>Concrete implementation of {@link WebContext} suitable for use in
* Servlets and JSP pages. The abstract methods are mapped to the appropriate
@@ -34,22 +32,18 @@ import java.util.Map;
*
* @version $Id$
*/
-
public class ServletWebContext extends WebContext {
private static final long serialVersionUID = 5852676730841544890L;
-
// ------------------------------------------------------------ Constructors
-
/**
* <p>Construct an uninitialized {@link ServletWebContext} instance.</p>
*/
public ServletWebContext() {
}
-
/**
* <p>Construct a {@link ServletWebContext} instance that is initialized
* with the specified Servlet API objects.</p>
@@ -61,134 +55,108 @@ public class ServletWebContext extends W
public ServletWebContext(ServletContext context,
HttpServletRequest request,
HttpServletResponse response) {
-
initialize(context, request, response);
-
}
-
// ------------------------------------------------------ Instance Variables
-
/**
* <p>The lazily instantiated <code>Map</code> of application scope
* attributes.</p>
*/
private Map<String, Object> applicationScope = null;
-
/**
* <p>The <code>ServletContext</code> for this web application.</p>
*/
private ServletContext context = null;
-
/**
* <p>The lazily instantiated <code>Map</code> of header name-value
* combinations (immutable).</p>
*/
private Map<String, String> header = null;
-
/**
* <p>The lazily instantitated <code>Map</code> of header name-values
* combinations (immutable).</p>
*/
private Map<String, String[]> headerValues = null;
-
/**
* <p>The lazily instantiated <code>Map</code> of context initialization
* parameters.</p>
*/
private Map<String, String> initParam = null;
-
/**
* <p>The lazily instantiated <code>Map</code> of cookies.</p>
*/
private Map<String, Cookie> cookieValues = null;
-
/**
* <p>The lazily instantiated <code>Map</code> of request
* parameter name-value.</p>
*/
private Map<String, String> param = null;
-
/**
* <p>The lazily instantiated <code>Map</code> of request
* parameter name-values.</p>
*/
private Map<String, String[]> paramValues = null;
-
/**
* <p>The <code>HttpServletRequest</code> for this request.</p>
*/
private HttpServletRequest request = null;
-
/**
* <p>The lazily instantiated <code>Map</code> of request scope
* attributes.</p>
*/
private Map<String, Object> requestScope = null;
-
/**
* <p>The <code>HttpServletResponse</code> for this request.</p>
*/
private HttpServletResponse response = null;
-
/**
* <p>The lazily instantiated <code>Map</code> of session scope
* attributes.</p>
*/
private Map<String, Object> sessionScope = null;
-
// ---------------------------------------------------------- Public Methods
-
/**
* <p>Return the {@link ServletContext} for this context.</p>
*
* @return The <code>ServletContext</code> for this context.
*/
public ServletContext getContext() {
-
- return (this.context);
-
+ return (this.context);
}
-
/**
* <p>Return the {@link HttpServletRequest} for this context.</p>
*
* @return The <code>HttpServletRequest</code> for this context.
*/
public HttpServletRequest getRequest() {
-
- return (this.request);
-
+ return (this.request);
}
-
/**
* <p>Return the {@link HttpServletResponse} for this context.</p>
*
* @return The <code>HttpServletResponse</code> for this context.
*/
public HttpServletResponse getResponse() {
-
- return (this.response);
-
+ return (this.response);
}
-
/**
* <p>Initialize (or reinitialize) this {@link ServletWebContext} instance
* for the specified Servlet API objects.</p>
@@ -200,17 +168,14 @@ public class ServletWebContext extends W
public void initialize(ServletContext context,
HttpServletRequest request,
HttpServletResponse response) {
-
// Save the specified Servlet API object references
this.context = context;
this.request = request;
this.response = response;
// Perform other setup as needed
-
}
-
/**
* <p>Release references to allocated resources acquired in
* <code>initialize()</code> of via subsequent processing. After this
@@ -218,7 +183,6 @@ public class ServletWebContext extends W
* <code>initialize()</code> will return undefined results.</p>
*/
public void release() {
-
// Release references to allocated collections
applicationScope = null;
header = null;
@@ -234,104 +198,82 @@ public class ServletWebContext extends W
context = null;
request = null;
response = null;
-
}
-
-
// ------------------------------------------------------ WebContext Methods
-
/**
* See the {@link WebContext}'s Javadoc.
*
* @return Application scope Map.
*/
public Map<String, Object> getApplicationScope() {
-
if ((applicationScope == null) && (context != null)) {
applicationScope = new ServletApplicationScopeMap(context);
}
return (applicationScope);
-
}
-
/**
* See the {@link WebContext}'s Javadoc.
*
* @return Header values Map.
*/
public Map<String, String> getHeader() {
-
if ((header == null) && (request != null)) {
header = new ServletHeaderMap(request);
}
return (header);
-
}
-
/**
* See the {@link WebContext}'s Javadoc.
*
* @return Header values Map.
*/
public Map<String, String[]> getHeaderValues() {
-
if ((headerValues == null) && (request != null)) {
headerValues = new ServletHeaderValuesMap(request);
}
return (headerValues);
-
}
-
/**
* See the {@link WebContext}'s Javadoc.
*
* @return Initialization parameter Map.
*/
public Map<String, String> getInitParam() {
-
if ((initParam == null) && (context != null)) {
initParam = new ServletInitParamMap(context);
}
return (initParam);
-
}
-
/**
* See the {@link WebContext}'s Javadoc.
*
* @return Request parameter Map.
*/
public Map<String, String> getParam() {
-
if ((param == null) && (request != null)) {
param = new ServletParamMap(request);
}
return (param);
-
}
-
/**
* See the {@link WebContext}'s Javadoc.
*
* @return Request parameter Map.
*/
public Map<String, String[]> getParamValues() {
-
if ((paramValues == null) && (request != null)) {
paramValues = new ServletParamValuesMap(request);
}
return (paramValues);
-
}
-
/**
* See the {@link WebContext}'s Javadoc.
*
@@ -339,27 +281,22 @@ public class ServletWebContext extends W
* @since Chain 1.1
*/
public Map<String, Cookie> getCookies() {
-
if ((cookieValues == null) && (request != null)) {
cookieValues = new ServletCookieMap(request);
}
return (cookieValues);
-
}
-
/**
* See the {@link WebContext}'s Javadoc.
*
* @return Request scope Map.
*/
public Map<String, Object> getRequestScope() {
-
if ((requestScope == null) && (request != null)) {
requestScope = new ServletRequestScopeMap(request);
}
return (requestScope);
-
}
@@ -369,13 +306,10 @@ public class ServletWebContext extends W
* @return Session scope Map.
*/
public Map<String, Object> getSessionScope() {
-
if ((sessionScope == null) && (request != null)) {
sessionScope = new ServletSessionScopeMap(request);
}
return (sessionScope);
-
}
-
}