cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r567666 - in /cocoon/trunk: blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/ core/cocoon-core/src/test/resources/org/apache/cocoon/components/treeprocessor/variables/ core/cocoon-pipeline/cocoo...
Date Mon, 20 Aug 2007 12:24:15 GMT
Author: gkossakowski
Date: Mon Aug 20 05:24:14 2007
New Revision: 567666

URL: http://svn.apache.org/viewvc?rev=567666&view=rev
Log:
COCOON-2122: Added support for calls of methods inside pipelineComponent scope (previously,
each call created new scope and it led to NPEs)
COCOON-2124: Changed scope of Object Model to pipelineComponent.
* ObjectModel configuration in cocoon-expression-language-impl is just a template. Actual
definition of ObjectModel bean is in cocoon-pipeline-impl because Object Model is bound to
pipelineComponent scope, now.
* Redefinied ObjectModel in tests using newly introduced bean configuration template.
* Introduced PipelinecomponentScopeHolder interface, this allows me to remove dependency on
cglib.

Added:
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolderImpl.java
  (contents, props changed)
      - copied, changed from r567436, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
    cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.spring.xml
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentProxyDecorator.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/PipelineComponentScope.xml

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml?rev=567666&r1=567665&r2=567666&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
Mon Aug 20 05:24:14 2007
@@ -29,16 +29,9 @@
   <import resource="classpath:META-INF/cocoon/spring/RhinoScope.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/AbstractStringTemplateParser.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/LegacyStringTemplateParser.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/ObjectModelTemplate.xml"/>
   
-  <!-- Redefining this bean instead of importing because originally it is in "call" scope
-->
-  <bean name="org.apache.cocoon.objectmodel.ObjectModel" class="org.apache.cocoon.objectmodel.ObjectModelImpl">
-    <property name="initialEntries">
-      <map>
-        <entry key="cocoon" value-ref="org.apache.cocoon.objectmodel.provider.CocoonEntryObjectModelProvider"/>
-        <entry key="Packages" value-ref="org.apache.cocoon.objectmodel.provider.PackagesEntryObjectModelProvider"/>
-        <entry key="java" value-ref="org.apache.cocoon.objectmodel.provider.JavaEntryObjectModelProvider"/>
-      </map>
-    </property>        
-  </bean>
+  <bean name="org.apache.cocoon.objectmodel.ObjectModel" class="org.apache.cocoon.objectmodel.ObjectModelImpl"
+        parent="org.apache.cocoon.objectmodel.ObjectModel.template"/>
   
 </beans>

Modified: cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.spring.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.spring.xml?rev=567666&r1=567665&r2=567666&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.spring.xml
(original)
+++ cocoon/trunk/core/cocoon-core/src/test/resources/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.spring.xml
Mon Aug 20 05:24:14 2007
@@ -26,16 +26,9 @@
   <import resource="classpath:META-INF/cocoon/spring/ObjectModelProviders.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/CocoonEntryObjectModelProvider.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/RhinoScope.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/ObjectModelTemplate.xml"/>
   
-  <!-- Redefining this bean instead of importing because originally it is in "call" scope
-->
-  <bean name="org.apache.cocoon.objectmodel.ObjectModel" class="org.apache.cocoon.objectmodel.ObjectModelImpl">
-    <property name="initialEntries">
-      <map>
-        <entry key="cocoon" value-ref="org.apache.cocoon.objectmodel.provider.CocoonEntryObjectModelProvider"/>
-        <entry key="Packages" value-ref="org.apache.cocoon.objectmodel.provider.PackagesEntryObjectModelProvider"/>
-        <entry key="java" value-ref="org.apache.cocoon.objectmodel.provider.JavaEntryObjectModelProvider"/>
-      </map>
-    </property>        
-  </bean>
+  <bean name="org.apache.cocoon.objectmodel.ObjectModel" class="org.apache.cocoon.objectmodel.ObjectModelImpl"
+        parent="org.apache.cocoon.objectmodel.ObjectModel.template"/>
   
 </beans>

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml?rev=567666&r1=567665&r2=567666&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml Mon Aug 20 05:24:14 2007
@@ -116,11 +116,6 @@
       <artifactId>servlet-api</artifactId>
       <scope>provided</scope>
     </dependency>
-    <dependency>
-      <groupId>cglib</groupId>
-      <artifactId>cglib</artifactId>
-      <version>2.1_3</version>
-    </dependency>    
     <!-- Test Dependencies -->
     <dependency>
       <groupId>xmlunit</groupId>

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentProxyDecorator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentProxyDecorator.java?rev=567666&r1=567665&r2=567666&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentProxyDecorator.java
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentProxyDecorator.java
Mon Aug 20 05:24:14 2007
@@ -20,6 +20,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
@@ -66,21 +67,31 @@
         public ScopeChangerProxy(Object wrapped, PipelineComponentScopeHolder holder) {
             this.wrapped = wrapped;
             this.holder = holder;
+            this.beans = new HashMap();
+            this.destructionCallbacks = new HashMap();
         }
 
         public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
-            Map currentBeans = null;
-            Map currentDestructionCallbacks = null;
             Object result;
+            boolean modified = false;
             try {
-                currentBeans = holder.getBeans();
-                currentDestructionCallbacks = holder.getDestructionCallbacks();
-                holder.setBeans(beans);
-                holder.setDestructionCallbacks(destructionCallbacks);
+                if (!holder.getInScope()) {
+                    holder.setParentBeans(holder.getBeans());
+                    holder.setParentDestructionCallbacks(holder.getDestructionCallbacks());
+                    holder.setBeans(beans);
+                    holder.setDestructionCallbacks(destructionCallbacks);
+                    holder.setInScope(true);
+                    modified = true;
+                }
                 result = method.invoke(wrapped, args);
             } finally {
-                holder.setBeans(currentBeans);
-                holder.setDestructionCallbacks(currentDestructionCallbacks);
+                if (modified) {
+                    holder.setBeans(holder.getParentBeans());
+                    holder.setDestructionCallbacks(holder.getParentDestructionCallbacks());
+                    holder.setParentBeans(null);
+                    holder.setParentDestructionCallbacks(null);
+                    holder.setInScope(false);
+                }
             }
             return result;
         }

Added: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java?rev=567666&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
(added)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
Mon Aug 20 05:24:14 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.components.pipeline.spring;
+
+import java.util.Map;
+
+public interface PipelineComponentScopeHolder {
+    //FIXME: This interface needs redesign
+
+    public Map getBeans();
+
+    public void setBeans(Map beans);
+    
+    public Map getParentBeans();
+    
+    public void setParentBeans(Map parentBeans);
+
+    public Map getDestructionCallbacks();
+
+    public void setDestructionCallbacks(Map destructionCallbacks);
+    
+    public Map getParentDestructionCallbacks();
+
+    public void setParentDestructionCallbacks(Map destructionCallbacks);
+    
+    public void setInScope(boolean inScope);
+    
+    public boolean getInScope();
+
+}
\ No newline at end of file

Copied: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolderImpl.java
(from r567436, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java)
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolderImpl.java?p2=cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolderImpl.java&p1=cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java&r1=567436&r2=567666&rev=567666&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolderImpl.java
Mon Aug 20 05:24:14 2007
@@ -19,37 +19,85 @@
 import java.util.HashMap;
 import java.util.Map;
 
-public class PipelineComponentScopeHolder {
+public class PipelineComponentScopeHolderImpl implements PipelineComponentScopeHolder {
     private Map beans;
     private Map destructionCallbacks;
+    
+    private Map parentBeans;
+    private Map parentDestructionCallbacks;
+    
     private boolean inScope;
     
-    public PipelineComponentScopeHolder() {
+    public PipelineComponentScopeHolderImpl() {
         beans = new HashMap();
         destructionCallbacks = new HashMap();
+        parentBeans = null;
+        parentDestructionCallbacks = null;
+        inScope = false;
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#getBeans()
+     */
     public Map getBeans() {
         return beans;
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#setBeans(java.util.Map)
+     */
     public void setBeans(Map beans) {
         this.beans = beans;
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#getDestructionCallbacks()
+     */
     public Map getDestructionCallbacks() {
         return destructionCallbacks;
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#setDestructionCallbacks(java.util.Map)
+     */
     public void setDestructionCallbacks(Map destructionCallbacks) {
         this.destructionCallbacks = destructionCallbacks;
     }
 
-    public boolean isInScope() {
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#getParentBeans()
+     */
+    public Map getParentBeans() {
+        return parentBeans;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#getParentDestructionCallbacks()
+     */
+    public Map getParentDestructionCallbacks() {
+        return parentDestructionCallbacks;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#setParentBeans()
+     */
+    public void setParentBeans(Map parentBeans) {
+        this.parentBeans = parentBeans;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder#setParentDestructionCallbacks(java.util.Map)
+     */
+    public void setParentDestructionCallbacks(Map destructionCallbacks) {
+        this.parentDestructionCallbacks = destructionCallbacks;
+    }
+
+    public boolean getInScope() {
         return inScope;
     }
 
     public void setInScope(boolean inScope) {
         this.inScope = inScope;
     }
+
 }

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolderImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml?rev=567666&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
(added)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
Mon Aug 20 05:24:14 2007
@@ -0,0 +1,31 @@
+<?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">
+  
+  <!-- Default implementation of ObjectModel interface in pipelineComponent scope. -->
+  <bean name="org.apache.cocoon.objectmodel.ObjectModel" class="org.apache.cocoon.objectmodel.ObjectModelImpl"

+        scope="pipelineComponent" parent="org.apache.cocoon.objectmodel.ObjectModel.template">
+    <aop:scoped-proxy proxy-target-class="false"/>
+  </bean>
+  
+</beans>
\ No newline at end of file

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/PipelineComponentScope.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/PipelineComponentScope.xml?rev=567666&r1=567665&r2=567666&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/PipelineComponentScope.xml
(original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/resources/META-INF/cocoon/spring/PipelineComponentScope.xml
Mon Aug 20 05:24:14 2007
@@ -36,8 +36,8 @@
   </bean>
   
   <bean id="org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder"
-        class="org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolder"
scope="call">
-    <aop:scoped-proxy/>
+        class="org.apache.cocoon.components.pipeline.spring.PipelineComponentScopeHolderImpl"
scope="call">
+    <aop:scoped-proxy proxy-target-class="false"/>
   </bean>
   
   <bean id="org.apache.cocoon.components.pipeline.spring.PipelineComponentProxyDecorator"



Mime
View raw message