cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r504719 - in /cocoon/trunk/core/cocoon-servlet-service: cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/ cocoon-servlet...
Date Wed, 07 Feb 2007 22:17:37 GMT
Author: danielf
Date: Wed Feb  7 14:17:36 2007
New Revision: 504719

URL: http://svn.apache.org/viewvc?view=rev&rev=504719
Log:
Continued work on using dependency injection for call stack objects. It seem to work for the
block property module. For the block path module a new interface for the ServletServiceContext.absolutizeURI()
method is probably needed to make it work.
For the moment the code is inactivated as the CGLIB based dynamic proxy doesn't work in some
environments.

Added:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java
  (with props)
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/resources/META-INF/cocoon/spring/cocoon-servletservice-context.xml
  (with props)
Modified:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPathModule.java
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPropertyModule.java
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-path-module.xml
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-property-module.xml

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPathModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPathModule.java?view=diff&rev=504719&r1=504718&r2=504719
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPathModule.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPathModule.java
Wed Feb  7 14:17:36 2007
@@ -22,11 +22,11 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.servlet.ServletContext;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.components.modules.input.InputModule;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.servletservice.CallStackHelper;
 import org.apache.cocoon.servletservice.ServletServiceContext;
 
@@ -36,13 +36,21 @@
  * @version $Id: BlockPathModule.java 448464 2006-09-21 05:29:11Z crossley $
  */
 public class BlockPathModule implements InputModule {
+    
+    private ServletContext servletContext;
+
+    public void setServletContext(ServletContext servletContext) {
+        this.servletContext = servletContext;
+    }
 
     public Object getAttribute( String name, Configuration modeConf, Map objectModel )
     throws ConfigurationException {
-        Environment env = EnvironmentHelper.getCurrentEnvironment();
-        ServletServiceContext blockContext = (ServletServiceContext) CallStackHelper.getBaseServletContext();
+        // FIXME Will be removed when the scoped proxy work
+        if (this.servletContext == null)
+            this.servletContext = CallStackHelper.getBaseServletContext();
         String absoluteURI = null;
         /* No relative block paths yet
+        Environment env = EnvironmentHelper.getCurrentEnvironment();
         String baseURI = env.getURIPrefix();
         if (baseURI.length() == 0 || !baseURI.startsWith("/"))
             baseURI = "/" + baseURI;
@@ -50,7 +58,7 @@
         try {
             // URI uri = ServletSource.resolveURI(new URI(name), new URI(null, null, baseURI,
null));
             URI uri = new URI(name);
-            absoluteURI= blockContext.absolutizeURI(uri).toString();
+            absoluteURI = ((ServletServiceContext)this.servletContext).absolutizeURI(uri).toString();
         } catch (URISyntaxException e) {
             throw new ConfigurationException("Couldn't absolutize " + name);
         }

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPropertyModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPropertyModule.java?view=diff&rev=504719&r1=504718&r2=504719
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPropertyModule.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/BlockPropertyModule.java
Wed Feb  7 14:17:36 2007
@@ -20,6 +20,8 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.servlet.ServletContext;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.components.modules.input.InputModule;
@@ -32,9 +34,18 @@
  */
 public class BlockPropertyModule implements InputModule {
 
+    private ServletContext servletContext;
+
+    public void setServletContext(ServletContext servletContext) {
+        this.servletContext = servletContext;
+    }
+
     public Object getAttribute( String name, Configuration modeConf, Map objectModel )
     throws ConfigurationException {
-        return CallStackHelper.getBaseServletContext().getInitParameter(name);
+        // FIXME Will be removed when the scoped proxy work
+        if (this.servletContext == null)
+            this.servletContext = CallStackHelper.getBaseServletContext();
+        return this.servletContext.getInitParameter(name);
     }
 
     public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-path-module.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-path-module.xml?view=diff&rev=504719&r1=504718&r2=504719
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-path-module.xml
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-path-module.xml
Wed Feb  7 14:17:36 2007
@@ -20,6 +20,9 @@
        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">
 
-  <bean name="org.apache.cocoon.components.modules.input.InputModule/block-path" class="org.apache.cocoon.servletservice.components.BlockPathModule"/>
+    <bean name="org.apache.cocoon.components.modules.input.InputModule/block-path"
+          class="org.apache.cocoon.servletservice.components.BlockPathModule">
+        <!--property name="servletContext" ref="javax.servlet.ServletContext/baseframe"/-->
+    </bean>
 
 </beans>

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-property-module.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-property-module.xml?view=diff&rev=504719&r1=504718&r2=504719
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-property-module.xml
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/resources/META-INF/cocoon/spring/cocoon-servlet-service-block-property-module.xml
Wed Feb  7 14:17:36 2007
@@ -20,6 +20,9 @@
        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">
 
-  <bean name="org.apache.cocoon.components.modules.input.InputModule/block-property" class="org.apache.cocoon.servletservice.components.BlockPropertyModule"/>
+	<bean name="org.apache.cocoon.components.modules.input.InputModule/block-property"
+	      class="org.apache.cocoon.servletservice.components.BlockPropertyModule">
+	    <!--property name="servletContext" ref="javax.servlet.ServletContext/baseframe"/-->
+    </bean>
 
 </beans>

Added: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java?view=auto&rev=504719
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java
(added)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java
Wed Feb  7 14:17:36 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.servletservice.spring;
+
+import javax.servlet.ServletContext;
+
+import org.apache.cocoon.servletservice.CallStackHelper;
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * Factorybean that exposes the ServletContext in the current base call frame.
+ * It will typically be used together with the call scope for servlet services.
+ * @version $Id$
+ */
+public final class BaseServletContextFactoryBean implements FactoryBean {
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#getObject()
+     */
+    public Object getObject() throws Exception {
+        return CallStackHelper.getBaseServletContext();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+     */
+    public Class getObjectType() {
+        return ServletContext.class;
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+     */
+    public boolean isSingleton() {
+        return true;
+    }
+
+}

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/resources/META-INF/cocoon/spring/cocoon-servletservice-context.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/resources/META-INF/cocoon/spring/cocoon-servletservice-context.xml?view=auto&rev=504719
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/resources/META-INF/cocoon/spring/cocoon-servletservice-context.xml
(added)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/resources/META-INF/cocoon/spring/cocoon-servletservice-context.xml
Wed Feb  7 14:17:36 2007
@@ -0,0 +1,32 @@
+<?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.0.xsd
+                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
+
+    <!-- The context object of the current base call frame -->
+    <bean name="javax.servlet.ServletContext/baseframe"
+          class="org.apache.cocoon.servletservice.spring.BaseServletContextFactoryBean"
+          scope="call">
+        <!--aop:scoped-proxy proxy-target-class="false"/-->
+    </bean>
+
+</beans>

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/resources/META-INF/cocoon/spring/cocoon-servletservice-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/resources/META-INF/cocoon/spring/cocoon-servletservice-context.xml
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message