cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r450869 - in /cocoon/trunk/core/cocoon-core/src/main: java/org/apache/cocoon/core/container/spring/ java/org/apache/cocoon/processing/impl/ resources/META-INF/spring/ resources/org/apache/cocoon/
Date Thu, 28 Sep 2006 14:35:31 GMT
Author: cziegeler
Date: Thu Sep 28 07:35:30 2006
New Revision: 450869

URL: http://svn.apache.org/viewvc?view=rev&rev=450869
Log:
Make process info provider avalon free

Added:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ServletContextFactoryBean.java
  (with props)
Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java
    cocoon/trunk/core/cocoon-core/src/main/resources/META-INF/spring/cocoon-core-applicationContext.xml
    cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/cocoon.roles

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ServletContextFactoryBean.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ServletContextFactoryBean.java?view=auto&rev=450869
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ServletContextFactoryBean.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ServletContextFactoryBean.java
Thu Sep 28 07:35:30 2006
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+package org.apache.cocoon.core.container.spring;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.web.context.ServletContextAware;
+
+/**
+ * Simple Spring factory bean which provides the servlet context as a bean.
+ * This avoids a dependence to Springs ServletContextAware interface.
+ * @version $Id$
+ */
+public class ServletContextFactoryBean implements FactoryBean, ServletContextAware {
+
+    protected ServletContext servletContext;
+
+    /**
+     * @see org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet.ServletContext)
+     */
+    public void setServletContext(ServletContext context) {
+        this.servletContext = context;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.FactoryBean#getObject()
+     */
+    public Object getObject() throws Exception {
+        return this.servletContext;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+     */
+    public Class getObjectType() {
+        return ServletContext.class;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+     */
+    public boolean isSingleton() {
+        return true;
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ServletContextFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ServletContextFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java?view=diff&rev=450869&r1=450868&r2=450869
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
Thu Sep 28 07:35:30 2006
@@ -18,6 +18,8 @@
  */
 package org.apache.cocoon.core.container.spring;
 
+import javax.servlet.ServletContext;
+
 import org.apache.cocoon.configuration.Settings;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -58,9 +60,10 @@
         if ( runningMode != null ) {
             beanDef.getPropertyValues().addPropertyValue("runningMode", runningMode);
         }
-        // register
+        // register settings bean
         this.register(beanDef, Settings.ROLE, parserContext.getRegistry());
 
+        this.addComponent(ServletContextFactoryBean.class.getName(), ServletContext.class.getName(),
null, false, parserContext.getRegistry());
         return null;
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java?view=diff&rev=450869&r1=450868&r2=450869
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java
Thu Sep 28 07:35:30 2006
@@ -22,50 +22,50 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.Constants;
-import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.http.HttpEnvironment;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.processing.ProcessInfoProvider;
 
 /**
  * Default implementation of the process info provider.
  *
- * For a simpler implementation we currently use Avalon functionality.
- *
  * @version $Id$
  * @since 2.2
  */
 public class ProcessInfoProviderImpl
-    implements ProcessInfoProvider, ThreadSafe, Contextualizable {
-
-    protected Context context;
+    implements ProcessInfoProvider {
 
     protected ServletContext servletContext;
 
+    protected Map getCurrentObjectModel() {
+        final Environment env = EnvironmentHelper.getCurrentEnvironment();
+        if ( env == null ) {
+            throw new IllegalStateException("Unable to locate current environment.");
+        }
+        return env.getObjectModel();
+    }
+
     /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     * Set the dependency to the servlet context.
+     * @param context The servlet context.
      */
-    public void contextualize(Context aContext) throws ContextException {
-        this.context = aContext;
-        this.servletContext = (ServletContext) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
+    public void setServletContext(ServletContext context) {
+        this.servletContext = context;
     }
 
     /**
      * @see org.apache.cocoon.processing.ProcessInfoProvider#getRequest()
      */
     public HttpServletRequest getRequest() {
-        return (HttpServletRequest) ContextHelper.getObjectModel(this.context).get(HttpEnvironment.HTTP_REQUEST_OBJECT);
+        return (HttpServletRequest) this.getCurrentObjectModel().get(HttpEnvironment.HTTP_REQUEST_OBJECT);
     }
 
     /**
      * @see org.apache.cocoon.processing.ProcessInfoProvider#getResponse()
      */
     public HttpServletResponse getResponse() {
-        return (HttpServletResponse) ContextHelper.getObjectModel(this.context).get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
+        return (HttpServletResponse) this.getCurrentObjectModel().get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
     }
 
     /**
@@ -79,6 +79,6 @@
      * @see org.apache.cocoon.processing.ProcessInfoProvider#getObjectModel()
      */
     public Map getObjectModel() {
-        return ContextHelper.getObjectModel(this.context);
+        return this.getCurrentObjectModel();
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/resources/META-INF/spring/cocoon-core-applicationContext.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/resources/META-INF/spring/cocoon-core-applicationContext.xml?view=diff&rev=450869&r1=450868&r2=450869
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/resources/META-INF/spring/cocoon-core-applicationContext.xml
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/resources/META-INF/spring/cocoon-core-applicationContext.xml
Thu Sep 28 07:35:30 2006
@@ -17,5 +17,10 @@
   limitations under the License.
 -->
 
-<!-- @version $Id: applicationContext.xml 387946 2006-03-22 21:07:56Z cziegeler $ -->
-<beans/>
\ No newline at end of file
+<!-- @version $Id$ -->
+<beans>
+  <bean name="org.apache.cocoon.processing.ProcessInfoProvider"
+        class="org.apache.cocoon.processing.impl.ProcessInfoProviderImpl">
+    <property name="servletContext" ref="javax.servlet.ServletContext"/>
+  </bean>
+</beans>
\ No newline at end of file

Modified: cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/cocoon.roles
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/cocoon.roles?view=diff&rev=450869&r1=450868&r2=450869
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/cocoon.roles (original)
+++ cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/cocoon.roles Thu Sep
28 07:35:30 2006
@@ -46,10 +46,6 @@
         shorthand="source-resolver"
         default-class="org.apache.cocoon.components.source.CocoonSourceResolver"/>
 
-  <role name="org.apache.cocoon.processing.ProcessInfoProvider"
-        shorthand="process-info-provider"
-        default-class="org.apache.cocoon.processing.impl.ProcessInfoProviderImpl"/>
-
   <!-- The entity resolver used by most parsers -->
   <role name="org.apache.excalibur.xml.EntityResolver"
         shorthand="entity-resolver"



Mime
View raw message