cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r733733 - in /cocoon/cocoon3/trunk: cocoon-controller/src/main/java/org/apache/cocoon/controller/ cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/ cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/
Date Mon, 12 Jan 2009 13:21:55 GMT
Author: reinhard
Date: Mon Jan 12 05:21:53 2009
New Revision: 733733

URL: http://svn.apache.org/viewvc?rev=733733&view=rev
Log:
A controller pipeline component didn't set the content type. The invoke() method now returns
the content type which can be used by the pipeline controller component, which is a Finisher,
to set the content type as pipeline result.

Modified:
    cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/Controller.java
    cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/SpringControllerComponent.java
    cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java
    cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/StreamingResponse.java
    cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/URLResponse.java

Modified: cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/Controller.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/Controller.java?rev=733733&r1=733732&r2=733733&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/Controller.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/Controller.java
Mon Jan 12 05:21:53 2009
@@ -23,7 +23,14 @@
 
 public interface Controller {
 
-    void invoke(OutputStream outputStream, String string, Map<String, Object> inputParameters,
+    /**
+     * @param outputStream
+     * @param string
+     * @param inputParameters
+     * @param configuration
+     * 
+     * @return The mime-type of the returned output stream.
+     */
+    String invoke(OutputStream outputStream, String string, Map<String, Object> inputParameters,
             Map<String, ? extends Object> configuration);
-
 }

Modified: cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/SpringControllerComponent.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/SpringControllerComponent.java?rev=733733&r1=733732&r2=733733&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/SpringControllerComponent.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/SpringControllerComponent.java
Mon Jan 12 05:21:53 2009
@@ -37,6 +37,7 @@
     private Map<String, Object> parameters;
     private String selector;
     private Map<String, ? extends Object> configuration;
+    private String contentType;
 
     /**
      * {@inheritDoc}
@@ -46,7 +47,7 @@
     public void execute() {
         Controller controller = (Controller) this.applicationContext.getBean(Controller.class.getName()
+ "/"
                 + this.beanName, Controller.class);
-        controller.invoke(this.outputStream, this.selector, this.parameters, this.configuration);
+        this.contentType = controller.invoke(this.outputStream, this.selector, this.parameters,
this.configuration);
     }
 
     /**
@@ -55,7 +56,7 @@
      * @see org.apache.cocoon.pipeline.component.Finisher#getContentType()
      */
     public String getContentType() {
-        return null;
+        return this.contentType;
     }
 
     /**

Modified: cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java?rev=733733&r1=733732&r2=733733&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/SpringRESTController.java
Mon Jan 12 05:21:53 2009
@@ -56,10 +56,12 @@
 
 /**
  * <p>
- * This controller is responsible for the execution of instances of REST controller beans.
Note that each controller
- * implementation must be available as Spring bean. For that purpose you can use the {@link
RESTController} annotation
- * and load all beans from a particular package automatically. See
- * http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-classpath-scanning
for details.
+ * This controller is responsible for the execution of instances of REST
+ * controller beans. Note that each controller implementation must be available
+ * as Spring bean. For that purpose you can use the {@link RESTController}
+ * annotation and load all beans from a particular package automatically. See
+ * http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-classpath-scanning
+ * for details.
  * </p>
  */
 public class SpringRESTController implements Controller, ApplicationContextAware {
@@ -70,7 +72,7 @@
 
     private MethodDelegator methodDelegator;
 
-    public void invoke(OutputStream outputStream, String functionName, Map<String, Object>
inputParameters,
+    public String invoke(OutputStream outputStream, String functionName, Map<String, Object>
inputParameters,
             Map<String, ? extends Object> configuration) {
         if (!this.applicationContext.isPrototype(functionName)) {
             throw new ProcessingException("A REST controller bean MUST run within the 'prototype'
scope.");
@@ -88,11 +90,13 @@
             if (restResponse instanceof Status) {
                 StatusCodeCollector.setStatusCode(((Status) restResponse).getStatus());
             } else if (restResponse instanceof StreamingResponse) {
-                ((StreamingResponse) restResponse).stream(outputStream, inputParameters);
+                return ((StreamingResponse) restResponse).stream(outputStream, inputParameters);
             }
         } catch (Exception e) {
             throw ExceptionHandler.getInvocationException(e);
         }
+
+        return null;
     }
 
     public void setAnnotationCollector(AnnotationCollector annotationCollector) {

Modified: cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/StreamingResponse.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/StreamingResponse.java?rev=733733&r1=733732&r2=733733&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/StreamingResponse.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/StreamingResponse.java
Mon Jan 12 05:21:53 2009
@@ -20,9 +20,10 @@
 import java.util.Map;
 
 /**
- * This interface can be used as {@link RestResponse} if the result of a controller is a
{@link OutputStream}.
+ * This interface can be used as {@link RestResponse} if the result of a
+ * controller is a {@link OutputStream}.
  */
 public interface StreamingResponse extends RestResponse {
 
-    void stream(OutputStream outputStream, Map<String, Object> inputParameters) throws
Exception;
+    String stream(OutputStream outputStream, Map<String, Object> inputParameters) throws
Exception;
 }

Modified: cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/URLResponse.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/URLResponse.java?rev=733733&r1=733732&r2=733733&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/URLResponse.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-rest/src/main/java/org/apache/cocoon/rest/controller/response/URLResponse.java
Mon Jan 12 05:21:53 2009
@@ -68,13 +68,15 @@
         return this.url;
     }
 
-    public void stream(OutputStream outputStream, Map<String, Object> inputParameters)
throws Exception {
+    public String stream(OutputStream outputStream, Map<String, Object> inputParameters)
throws Exception {
         URLConnection servletConnection = null;
         try {
             ControllerContextHelper.storeContext(this.data, inputParameters);
 
             servletConnection = this.url.openConnection();
             IOUtils.copy(servletConnection.getInputStream(), outputStream);
+
+            return servletConnection.getContentEncoding();
         } finally {
             URLConnectionUtils.closeQuietly(servletConnection);
         }



Mime
View raw message