You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2007/02/22 14:06:30 UTC

svn commit: r510491 - in /cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src: changes/changes.xml main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java

Author: reinhard
Date: Thu Feb 22 05:06:30 2007
New Revision: 510491

URL: http://svn.apache.org/viewvc?view=rev&rev=510491
Log:
WebAppContextUtils stored a Spring parent application context in a static field. This
made it impossible to reload the context. The static field was removed and a request
for the parent context results in WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext)
which returns the parent Spring application context stored in the servlet context.

Modified:
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/changes/changes.xml
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/changes/changes.xml?view=diff&rev=510491&r1=510490&r2=510491
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/changes/changes.xml (original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/changes/changes.xml Thu Feb 22 05:06:30 2007
@@ -22,28 +22,34 @@
     |
     | @version $Id$
     +-->
-<document>
-  <body>
-    <release version="1.0.1" date="2007-00-00" description="unreleased">
-     <action dev="cziegeler" type="add">
-       Each property reference can have an optional default value, like
-       ${my.property.net:THE DEFAULT}. If no other definition for this
-       property is found, the default is used.
-     </action>  
-     <action dev="cziegeler" type="add">
-       Add a bean map that collects all beans from the Spring context
-       conforming to a specified type.
-     </action>
-    </release>
-    <release version="1.0.0" date="2007-00-00" description="unreleased">  
-     <action dev="cziegeler" type="add">
-        Improved the DefaultBlockResourcesHolder to act like a PropertyPlaceholderConfigurer.
-        This allows access to the path of the deployed blocks in the configuration files
-        through properties like ${org.apache.cocoon.blocks.[BLOCK_NAME].resources}.
-      </action>      
-     <action dev="cziegeler" type="add">
-        Initial creation.
-      </action>      
-    </release>
-  </body>
-</document>
+    <document>
+      <body>
+        <release version="1.0.1" date="2007-00-00" description="unreleased">
+          <action dev="reinhard" type="fix">
+            WebAppContextUtils stored a Spring parent application context in a static field. This
+            made it impossible to reload the context. The static field was removed and a request
+            for the parent context results in 
+            WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext)
+            which returns the parent Spring application context stored in the servlet context.
+          </action>             
+          <action dev="cziegeler" type="add">
+            Each property reference can have an optional default value, like
+            ${my.property.net:THE DEFAULT}. If no other definition for this
+            property is found, the default is used.
+          </action>  
+          <action dev="cziegeler" type="add">
+            Add a bean map that collects all beans from the Spring context
+            conforming to a specified type.
+          </action>
+          <action dev="cziegeler" type="add">
+            Improved the DefaultBlockResourcesHolder to act like a PropertyPlaceholderConfigurer.
+            This allows access to the path of the deployed blocks in the configuration files
+            through properties like ${org.apache.cocoon.blocks.[BLOCK_NAME].resources}.
+          </action>      
+          <action dev="cziegeler" type="add">
+            Initial creation.
+          </action>      
+        </release>
+      </body>
+    </document>
+    
\ No newline at end of file

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java?view=diff&rev=510491&r1=510490&r2=510491
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java (original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java Thu Feb 22 05:06:30 2007
@@ -16,8 +16,6 @@
  */
 package org.apache.cocoon.spring.configurator;
 
-import javax.servlet.ServletContext;
-
 import org.apache.cocoon.spring.configurator.impl.ServletContextFactoryBean;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.request.RequestAttributes;
@@ -35,8 +33,6 @@
     /** The name of the request attribute containing the current bean factory. */
     public static final String CONTAINER_REQUEST_ATTRIBUTE = WebAppContextUtils.class.getName();
 
-    protected static WebApplicationContext ROOT_CONTAINER;
-
     /**
      * Get the current web application context.
      * @throws IllegalStateException if no WebApplicationContext could not be found
@@ -48,7 +44,7 @@
     }
 
     /**
-     * Return the current web application context.
+     * Return the current web application context or if the attributes are null, the parent context.
      * @param attributes     The request attributes.
      * @throws IllegalStateException if no WebApplicationContext could not be found
      * @return The web application context.
@@ -59,12 +55,8 @@
                 return (WebApplicationContext) attributes.getAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
             }
         }
-        if ( ROOT_CONTAINER == null ) {
-            final ServletContext servletContext = ServletContextFactoryBean.getServletContext();
-            final WebApplicationContext parentContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
-            ROOT_CONTAINER = parentContext;
-        }
-        return ROOT_CONTAINER;
+        // return the root context
+        return WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContextFactoryBean.getServletContext());
     }
 
     /**