cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r676325 - in /cocoon/whiteboard/corona/trunk: corona-controller/src/main/java/org/apache/cocoon/corona/controller/ corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/ corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/...
Date Sun, 13 Jul 2008 14:14:57 GMT
Author: reinhard
Date: Sun Jul 13 07:14:56 2008
New Revision: 676325

URL: http://svn.apache.org/viewvc?rev=676325&view=rev
Log:
introduce the ControllerContextHelper to use a container for the objects passed from the controller
to the view
add controller context objects to the object model

Added:
    cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/
    cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java
  (with props)
Modified:
    cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/Controller.java
    cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/DemoControllerDispatcher.java
    cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/SpringControllerComponent.java
    cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
    cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/util/ObjectModelProvider.java

Modified: cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/Controller.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/Controller.java?rev=676325&r1=676324&r2=676325&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/Controller.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/Controller.java
Sun Jul 13 07:14:56 2008
@@ -23,7 +23,7 @@
 
 public interface Controller {
 
-    void invoke(OutputStream outputStream, String string, Map<String, ? extends Object>
inputParameters,
+    void invoke(OutputStream outputStream, String string, Map<String, Object> inputParameters,
             Map<String, ? extends Object> configuration);
 
 }

Modified: cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/DemoControllerDispatcher.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/DemoControllerDispatcher.java?rev=676325&r1=676324&r2=676325&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/DemoControllerDispatcher.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/DemoControllerDispatcher.java
Sun Jul 13 07:14:56 2008
@@ -26,7 +26,7 @@
 
 public class DemoControllerDispatcher implements Controller {
 
-    public void invoke(OutputStream outputStream, String select, Map<String, ? extends
Object> inputParameters,
+    public void invoke(OutputStream outputStream, String select, Map<String, Object>
inputParameters,
             Map<String, ? extends Object> configuration) {
         try {
             // URL url = new URL("servlet:/read/javascript-resource-explicit");

Modified: cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/SpringControllerComponent.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/SpringControllerComponent.java?rev=676325&r1=676324&r2=676325&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/SpringControllerComponent.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-controller/src/main/java/org/apache/cocoon/corona/controller/SpringControllerComponent.java
Sun Jul 13 07:14:56 2008
@@ -42,8 +42,8 @@
      * @see org.apache.cocoon.corona.pipeline.component.Starter#execute()
      */
     public void execute() {
-        Controller controller = (Controller) this.applicationContext.getBean(Controller.class.getName()
+ "/" + this.beanName,
-                Controller.class);
+        Controller controller = (Controller) this.applicationContext.getBean(Controller.class.getName()
+ "/"
+                + this.beanName, Controller.class);
         controller.invoke(this.outputStream, this.selector, this.parameters, this.configuration);
     }
 

Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java?rev=676325&r1=676324&r2=676325&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/SitemapServlet.java
Sun Jul 13 07:14:56 2008
@@ -212,7 +212,6 @@
                 String msg = "An exception occurred while building the sitemap.";
                 this.logger.error(msg, e);
                 ServletException servletException = new ServletException(msg, e);
-                servletException.initCause(e);
                 throw servletException;
             }
             this.initialized = true;

Added: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java?rev=676325&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java
(added)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java
Sun Jul 13 07:14:56 2008
@@ -0,0 +1,35 @@
+package org.apache.cocoon.corona.servlet.controller;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.corona.servlet.util.HttpContextHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ControllerContextHelper {
+
+    private static final Log LOG = LogFactory.getLog(ControllerContextHelper.class);
+
+    private static final String CONTEXT_OBJECT = ControllerContextHelper.class.getName();
+
+    @SuppressWarnings("unchecked")
+    public static Map<String, Object> getContext(Map<String, ? extends Object>
parameters) {
+        HttpServletRequest request = HttpContextHelper.getRequest(parameters);
+        Object controllerContext = request.getAttribute(CONTEXT_OBJECT);
+
+        if (controllerContext instanceof Map) {
+            return (Map<String, Object>) controllerContext;
+        }
+
+        LOG.warn("The parameters contain an entry with the key " + CONTEXT_OBJECT + " but
it is not a map.");
+        return Collections.EMPTY_MAP;
+    }
+
+    public static void storeContext(Map<String, Object> controllerContext, Map<String,
Object> parameters) {
+        HttpServletRequest request = HttpContextHelper.getRequest(parameters);
+        request.setAttribute(CONTEXT_OBJECT, controllerContext);
+    }
+}

Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/controller/ControllerContextHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/util/ObjectModelProvider.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/util/ObjectModelProvider.java?rev=676325&r1=676324&r2=676325&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/util/ObjectModelProvider.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-servlet/src/main/java/org/apache/cocoon/corona/servlet/util/ObjectModelProvider.java
Sun Jul 13 07:14:56 2008
@@ -21,12 +21,13 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 
+import org.apache.cocoon.corona.servlet.controller.ControllerContextHelper;
 import org.apache.cocoon.corona.sitemap.objectmodel.ObjectModel;
 
 public class ObjectModelProvider {
 
     public static ObjectModel provide(Map<String, Object> parameters) {
-        ObjectModel objectModel = new ObjectModel();
+        ObjectModel objectModel = new ObjectModel(parameters);
         Map<String, Object> corona = objectModel.getCoronaObject();
 
         HttpServletRequest request = HttpContextHelper.getRequest(parameters);
@@ -34,10 +35,17 @@
         corona.put("response", HttpContextHelper.getResponse(parameters));
         corona.put("context", HttpContextHelper.getServletContext(parameters));
         corona.put("settings", SettingsHelper.getSettings(parameters));
+        Map<String, Object> controllerContext = ControllerContextHelper.getContext(parameters);
+        if (controllerContext != null) {
+            corona.put("controller", controllerContext);
+        }
 
         return objectModel;
     }
 
+    /**
+     * A wrapper that can be used by expression languages to provide shortcuts to the request
parameters.
+     */
     public static class ObjectModelRequest extends HttpServletRequestWrapper {
 
         public ObjectModelRequest(HttpServletRequest request) {



Mime
View raw message