cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r501824 - in /cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon: SitemapElementParser.java SitemapHelper.java
Date Wed, 31 Jan 2007 12:12:01 GMT
Author: cziegeler
Date: Wed Jan 31 04:12:00 2007
New Revision: 501824

URL: http://svn.apache.org/viewvc?view=rev&rev=501824
Log:
No need to use own thread local variable; we can directly access the parent context.

Modified:
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java?view=diff&rev=501824&r1=501823&r2=501824
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
Wed Jan 31 04:12:00 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.cocoon.core.container.spring.avalon;
 
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 import org.springframework.beans.factory.support.RootBeanDefinition;
 import org.springframework.core.io.ResourceLoader;
@@ -62,7 +63,7 @@
      */
     protected ConfigurationInfo readConfiguration(String location, ResourceLoader resourceLoader)
     throws Exception {
-        WebApplicationContext parentContext = (WebApplicationContext)SitemapHelper.PARENT_CONTEXT.get();
+        WebApplicationContext parentContext = WebAppContextUtils.getCurrentWebApplicationContext();
         return ConfigurationReader.readSitemap((ConfigurationInfo)parentContext.getBean(ConfigurationInfo.class.getName()),
location, resourceLoader);
     }
 

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java?view=diff&rev=501824&r1=501823&r2=501824
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
Wed Jan 31 04:12:00 2007
@@ -38,7 +38,6 @@
 import org.apache.cocoon.util.Deprecation;
 import org.springframework.core.io.Resource;
 import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
 
 
 /**
@@ -48,8 +47,6 @@
  */
 public class SitemapHelper {
 
-    public static final ThreadLocal PARENT_CONTEXT = new ThreadLocal();
-
     private static final String CLASSLOADER_CONFIG_NAME = "classloader";
 
     private static final String DEFAULT_CONFIG_XCONF  = "config/avalon";
@@ -287,9 +284,9 @@
                                                         Monitor        fam,
                                                         ServletContext servletContext)
     throws Exception {
-        // let's get the root container first
-        final WebApplicationContext rootContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
-        final ProcessInfoProvider infoProvider = (ProcessInfoProvider) rootContext.getBean(ProcessInfoProvider.ROLE);
+        // let's get the parent container first
+        final WebApplicationContext parentContext = WebAppContextUtils.getCurrentWebApplicationContext();
+        final ProcessInfoProvider infoProvider = (ProcessInfoProvider) parentContext.getBean(ProcessInfoProvider.ROLE);
         final Request request = ObjectModelHelper.getRequest(infoProvider.getObjectModel());
         // let's determine our context url
         int pos = sitemapLocation.lastIndexOf('/');
@@ -298,7 +295,6 @@
         }
         final String contextUrl = sitemapLocation.substring(0, pos + 1);
 
-        final WebApplicationContext parentContext = WebAppContextUtils.getCurrentWebApplicationContext();
 
         // get classloader
 //      TODO rcl            
@@ -311,20 +307,15 @@
                                                    getBeanIncludes(parentContext, contextUrl,
config),
                                                    getPropertiesIncludes(parentContext, contextUrl,
config),
                                                    getGlobalSitemapVariables(config));
-        PARENT_CONTEXT.set(parentContext);
-        try {
-            final ChildXmlWebApplicationContext context = new ChildXmlWebApplicationContext(contextUrl,
-                                                                                        definition);
-            context.setServletContext(servletContext);
-            context.setParent(parentContext);
-            if ( classloader != null ) {
-                context.setClassLoader(classloader);
-            }
-            context.refresh();
-            return context;
-        } finally {
-            PARENT_CONTEXT.set(null);
+        final ChildXmlWebApplicationContext context = new ChildXmlWebApplicationContext(contextUrl,
+                                                                                    definition);
+        context.setServletContext(servletContext);
+        context.setParent(parentContext);
+        if ( classloader != null ) {
+            context.setClassLoader(classloader);
         }
+        context.refresh();
+        return context;
     }
 
 // TODO rcl    



Mime
View raw message