cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevend...@apache.org
Subject svn commit: r1155101 - /cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
Date Mon, 08 Aug 2011 21:13:30 GMT
Author: stevendolg
Date: Mon Aug  8 21:13:30 2011
New Revision: 1155101

URL: http://svn.apache.org/viewvc?rev=1155101&view=rev
Log:
Reworked class to fix warnings

Modified:
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java?rev=1155101&r1=1155100&r2=1155101&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/controller/ControllerContextHelper.java
Mon Aug  8 21:13:30 2011
@@ -32,12 +32,16 @@ import org.apache.commons.logging.LogFac
  * use e.g. the 'servlet:' protocol. This means that it is enough to store
  * objects that should be available in a sub-request into the current request.
  */
-public class ControllerContextHelper {
+public final class ControllerContextHelper {
 
     private static final Log LOG = LogFactory.getLog(ControllerContextHelper.class);
 
     private static final String CONTEXT_OBJECT = ControllerContextHelper.class.getName();
 
+    private ControllerContextHelper() {
+        // hide utility class constructor
+    }
+
     /**
      * Retrieve the current controller context from the Cocoon parameters.
      * 
@@ -47,15 +51,13 @@ public class ControllerContextHelper {
      */
     public static Map<String, Object> getContext(Map<String, ? extends Object>
parameters) {
         HttpServletRequest request = HttpContextHelper.getRequest(parameters);
-        Object controllerContext = request.getAttribute(CONTEXT_OBJECT);
+        Object value = request.getAttribute(CONTEXT_OBJECT);
 
-        if (controllerContext instanceof Map) {
-            @SuppressWarnings("unchecked")
-            Map<String, Object> result = (Map<String, Object>) controllerContext;
-            return result;
+        if (value instanceof Map) {
+            return asControllerContext(value);
         }
 
-        if (controllerContext != null) {
+        if (value != null) {
             LOG.warn("The parameters contain an entry with the key " + CONTEXT_OBJECT + "
but it is not a map.");
         }
         return Collections.emptyMap();
@@ -85,4 +87,9 @@ public class ControllerContextHelper {
     public static void storeContext(Map<String, Object> controllerContext, HttpServletRequest
request) {
         request.setAttribute(CONTEXT_OBJECT, controllerContext);
     }
+
+    @SuppressWarnings("unchecked")
+    private static Map<String, Object> asControllerContext(Object controllerContext)
{
+        return (Map<String, Object>) controllerContext;
+    }
 }



Mime
View raw message