cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r634988 - in /cocoon/whiteboard/micro/core: cocoon-core/src/main/java/org/apache/cocoon/servlet/ cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/ cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/...
Date Sat, 08 Mar 2008 15:17:52 GMT
Author: gkossakowski
Date: Sat Mar  8 07:17:51 2008
New Revision: 634988

URL: http://svn.apache.org/viewvc?rev=634988&view=rev
Log:
HttpEnvironment is a Spring bean now!
Moved initialization of HttpContext to HttpEnvironment.

Added:
    cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl.xml
Modified:
    cocoon/whiteboard/micro/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
    cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
    cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml

Modified: cocoon/whiteboard/micro/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java?rev=634988&r1=634987&r2=634988&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
Sat Mar  8 07:17:51 2008
@@ -17,16 +17,13 @@
 package org.apache.cocoon.servlet;
 
 import java.io.IOException;
+
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang.time.StopWatch;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-
 import org.apache.cocoon.ConnectionResetException;
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.Processor;
@@ -34,12 +31,12 @@
 import org.apache.cocoon.ResourceNotFoundException;
 import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.core.container.spring.logger.LoggerUtils;
-import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.http.HttpContext;
-import org.apache.cocoon.environment.http.HttpEnvironment;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.util.AbstractLogEnabled;
+import org.apache.commons.lang.time.StopWatch;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
  * This is the entry point for Cocoon execution as an HTTP Servlet.
@@ -56,15 +53,6 @@
     static final float MINUTE = 60 * SECOND;
     static final float HOUR   = 60 * MINUTE;
 
-    /** The servlet context. */
-    protected final ServletContext servletContext;
-
-    /** Cocoon environment context. */
-    protected final Context environmentContext;
-
-    /** Configured servlet container encoding. Defaults to ISO-8859-1. */
-    protected final String containerEncoding;
-
     /** Root Cocoon Bean Factory. */
     protected final BeanFactory cocoonBeanFactory;
 
@@ -85,19 +73,11 @@
 
 
     public RequestProcessor(ServletContext servletContext) {
-        this.servletContext = servletContext;
         this.cocoonBeanFactory = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
 
         this.settings = (Settings) this.cocoonBeanFactory.getBean(Settings.ROLE);
         this.servletSettings = new ServletSettings(this.settings);
 
-        final String encoding = this.settings.getContainerEncoding();
-        if (encoding == null) {
-            this.containerEncoding = "ISO-8859-1";
-        } else {
-            this.containerEncoding = encoding;
-        }
-
         // Obtain access logger
         String category = servletContext.getInitParameter("org.apache.cocoon.servlet.logger.access");
         if (category == null || category.length() == 0) {
@@ -106,7 +86,6 @@
         setLogger(LoggerUtils.getChildLogger(this.cocoonBeanFactory, category));
 
         this.processor = getProcessor();
-        this.environmentContext = new HttpContext(this.servletContext);
 
         // get the optional request listener
         if (this.cocoonBeanFactory.containsBean(RequestListener.ROLE)) {
@@ -139,7 +118,7 @@
 
         Environment env;
         try{
-            env = getEnvironment(request, res);
+            env = (Environment)cocoonBeanFactory.getBean("org.apache.cocoon.environment.http.HttpEnvironment");
         } catch (Exception e) {
             if (getLogger().isErrorEnabled()) {
                 getLogger().error("Problem with Cocoon servlet", e);
@@ -278,28 +257,6 @@
 
     protected String getURI(HttpServletRequest request, HttpServletResponse res) throws IOException
{
         return RequestUtil.getCompleteUri(request, res);
-    }
-
-    /**
-     * Create the environment for the request
-     */
-    protected Environment getEnvironment(HttpServletRequest req,
-                                         HttpServletResponse res)
-    throws Exception {
-
-        String formEncoding = req.getParameter("cocoon-form-encoding");
-        if (formEncoding == null) {
-            formEncoding = this.settings.getFormEncoding();
-        }
-
-        HttpEnvironment env;
-        env = new HttpEnvironment(req,
-                                  res,
-                                  this.servletContext,
-                                  this.environmentContext,
-                                  this.containerEncoding,
-                                  formEncoding);
-        return env;
     }
 
     private String processTime(long time) {

Modified: cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java?rev=634988&r1=634987&r2=634988&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
Sat Mar  8 07:17:51 2008
@@ -25,7 +25,6 @@
 
 import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.environment.AbstractEnvironment;
-import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.util.NetUtils;
 import org.apache.commons.logging.Log;
@@ -62,39 +61,6 @@
     private Settings settings;
     
     private ServletContext servletContext;
-
-    /**
-     * Constructs a HttpEnvironment object from a HttpServletRequest
-     * and HttpServletResponse objects
-     */
-    public HttpEnvironment(HttpServletRequest req,
-                           HttpServletResponse res,
-                           ServletContext servletContext,
-                           Context context,
-                           String containerEncoding,
-                           String defaultFormEncoding)
-    throws IOException {
-        super(getCompleteUri(req, res), null, null);
-
-        this.request = new HttpRequest(req, this);
-        this.request.setCharacterEncoding(defaultFormEncoding);
-        this.request.setContainerEncoding(containerEncoding);
-        this.response = new HttpResponse(res);
-
-        setView(extractView(this.request));
-        setAction(extractAction(this.request));
-
-        this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request);
-        this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, this.response);
-        this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT, context);
-
-        // This is a kind of a hack for the components that need
-        // the real servlet objects to pass them along to other
-        // libraries.
-        this.objectModel.put(HTTP_REQUEST_OBJECT, req);
-        this.objectModel.put(HTTP_RESPONSE_OBJECT, res);
-        this.objectModel.put(HTTP_SERVLET_CONTEXT, servletContext);
-    }
     
     public HttpEnvironment() { 
         super(null, null);
@@ -132,6 +98,22 @@
         this.objectModel.put(HTTP_RESPONSE_OBJECT, this.rawResponse);
         this.objectModel.put(HTTP_SERVLET_CONTEXT, this.servletContext);
     }
+    
+    public void setRawRequest(HttpServletRequest rawRequest) {
+        this.rawRequest = rawRequest;
+    }
+
+    public void setRawResponse(HttpServletResponse rawResponse) {
+        this.rawResponse = rawResponse;
+    }
+    
+    public void setSettings(Settings settings) {
+        this.settings = settings;
+    }
+    
+    public void setServletContext(ServletContext servletContext) {
+        this.servletContext = servletContext;
+    }
 
     /**
      *  Redirect the client to new URL
@@ -318,4 +300,5 @@
         }
         return uri;
     }
+    
 }

Modified: cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml?rev=634988&r1=634987&r2=634988&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
(original)
+++ cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
Sat Mar  8 07:17:51 2008
@@ -18,7 +18,7 @@
 <!-- SVN $Id$ -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 
   <!--+
       | This is the Cocoon cache. This component is responsible for storing

Added: cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl.xml?rev=634988&view=auto
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl.xml
(added)
+++ cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl.xml
Sat Mar  8 07:17:51 2008
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- SVN $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
+
+  <!--+
+      | This is the Cocoon cache. This component is responsible for storing
+      | and retrieving cached responses. It can be used to monitor the cache
+      | or the investigate which responses are cached etc.
+      |
+      | The cache uses the store to save its values.
+      +-->
+  <bean name="org.apache.cocoon.caching.Cache" class="org.apache.cocoon.caching.impl.CacheImpl">
+    <property name="store" ref="org.apache.excalibur.store.Store"/>
+  </bean>
+  
+  <bean name="org.apache.cocoon.environment.AbstractEnvironment" class="org.apache.cocoon.environment.AbstractEnvironment"
abstract="true"/>
+  
+  <bean name="org.apache.cocoon.environment.http.HttpEnvironment" class="org.apache.cocoon.environment.http.HttpEnvironment"
+        scope="call" parent="org.apache.cocoon.environment.AbstractEnvironment" init-method="init">
+    <aop:scoped-proxy proxy-target-class="false"/>
+    <property name="rawRequest" ref="javax.servlet.http.HttpServletRequest/callstack"/>
+    <property name="rawResponse" ref="javax.servlet.http.HttpServletResponse/callstack"/>
+    <property name="settings" ref="org.apache.cocoon.configuration.Settings"/>
+    <property name="servletContext" ref="javax.servlet.ServletContext/callstack"/>
+  </bean>
+
+</beans>
\ No newline at end of file



Mime
View raw message