cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r619427 - in /cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor: ConcreteTreeProcessor.java TreeProcessor.java
Date Thu, 07 Feb 2008 14:29:03 GMT
Author: reinhard
Date: Thu Feb  7 06:28:58 2008
New Revision: 619427

URL: http://svn.apache.org/viewvc?rev=619427&view=rev
Log:
reduce usage of servicemanager/webapplicationcontext

Modified:
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java

Modified: cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?rev=619427&r1=619426&r2=619427&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
Thu Feb  7 06:28:58 2008
@@ -30,12 +30,9 @@
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.sitemap.ExecutionContext;
 import org.apache.cocoon.sitemap.SitemapExecutor;
-import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationImpl;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
 /**
@@ -73,14 +70,10 @@
     /** Processor attributes */
     protected Map processorAttributes = new HashMap();
 
-    /** Container for this sitemap. */
-    protected WebApplicationContext webAppContext;
-
     /**
      * Builds a concrete processig, given the wrapping processor
      */
-    public ConcreteTreeProcessor(TreeProcessor wrappingProcessor,
-                                 SitemapExecutor sitemapExecutor) {
+    public ConcreteTreeProcessor(TreeProcessor wrappingProcessor, SitemapExecutor sitemapExecutor)
{
         // Store our wrapping processor
         this.wrappingProcessor = wrappingProcessor;
 
@@ -89,21 +82,19 @@
     }
 
     /** Set the processor data, result of the treebuilder job */
-    public void setProcessorData(WebApplicationContext webAppContext,
-                                 ProcessingNode rootNode,
-                                 List disposableNodes) {
+    public void setProcessorData(WebApplicationContext webAppContext, ProcessingNode rootNode,
List disposableNodes) {
         if (this.rootNode != null) {
             throw new IllegalStateException("setProcessorData() can only be called once");
         }
-        this.webAppContext = webAppContext;
-        this.manager = (ServiceManager)this.webAppContext.getBean(AvalonUtils.SERVICE_MANAGER_ROLE);
+        this.manager = (ServiceManager) webAppContext.getBean(AvalonUtils.SERVICE_MANAGER_ROLE);
         this.rootNode = rootNode;
         this.disposableNodes = disposableNodes;
     }
 
     /**
-     * Mark this processor as needing to be disposed. Actual call to {@link #dispose()} will
occur when
-     * all request processings on this processor will be terminated.
+     * Mark this processor as needing to be disposed. Actual call to
+     * {@link #dispose()} will occur when all request processings on this
+     * processor will be terminated.
      */
     public void markForDisposal() {
         // Decrement the request count (negative number means dispose)
@@ -147,18 +138,16 @@
      * @return true if the pipeline was successfully built, false otherwise.
      * @throws Exception
      */
-    protected boolean process(Environment environment, InvokeContext context)
-    throws Exception {
+    protected boolean process(Environment environment, InvokeContext context) throws Exception
{
 
         // Increment the concurrent requests count
         synchronized (this) {
             requestCount++;
         }
 
-        Object handle = null;
         try {
-            handle = WebAppContextUtils.enteringContext(this.webAppContext);
-            this.sitemapExecutor.enterSitemap(this, environment.getObjectModel(), this.wrappingProcessor.source.getURI());
+            this.sitemapExecutor.enterSitemap(this, environment.getObjectModel(), this.wrappingProcessor.source
+                    .getURI());
 
             // and now process
             EnvironmentHelper.enterProcessor(this, environment);
@@ -176,10 +165,7 @@
                 context.setRedirector(oldRedirector);
             }
         } finally {
-            if (handle != null) {
-                this.sitemapExecutor.leaveSitemap(this, environment.getObjectModel());
-                WebAppContextUtils.leavingContext(this.webAppContext, handle);
-            }
+            this.sitemapExecutor.leaveSitemap(this, environment.getObjectModel());
             markForDisposal();
         }
     }
@@ -200,15 +186,6 @@
         // Ensure it won't be used anymore
         this.rootNode = null;
         this.sitemapExecutor = null;
-
-        if ( this.webAppContext != null ) {
-            if ( webAppContext instanceof ConfigurableApplicationContext ) {
-                ((ConfigurableApplicationContext)webAppContext).close();
-            } else if ( webAppContext instanceof ConfigurableBeanFactory ) {
-                ((ConfigurableBeanFactory)webAppContext).destroySingletons();
-            }
-            this.webAppContext = null;
-        }
     }
 
     public String getContext() {

Modified: cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java?rev=619427&r1=619426&r2=619427&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
Thu Feb  7 06:28:58 2008
@@ -243,7 +243,7 @@
         }
 
         long startTime = System.currentTimeMillis();
-        ConcreteTreeProcessor newProcessor;
+        ConcreteTreeProcessor concreteTreeProcessor;
         ConcreteTreeProcessor oldProcessor = this.concreteProcessor;
 
         if (oldProcessor != null) {
@@ -274,14 +274,14 @@
 
             Configuration sitemapProgram = createSitemapProgram(this.source);
 
-            newProcessor = new ConcreteTreeProcessor(this, this.sitemapExecutor);
+            concreteTreeProcessor = new ConcreteTreeProcessor(this, this.sitemapExecutor);
 
             // Get the treebuilder that can handle this version of the sitemap.
             TreeBuilder treeBuilder = getTreeBuilder(sitemapProgram);
             try {
-                treeBuilder.setProcessor(newProcessor);
+                treeBuilder.setProcessor(concreteTreeProcessor);
                 ProcessingNode root = treeBuilder.build(sitemapProgram, this.source.getURI());
-                newProcessor.setProcessorData(
+                concreteTreeProcessor.setProcessorData(
                         treeBuilder.getWebApplicationContext(),
                         root,
                         treeBuilder.getDisposableNodes());
@@ -294,7 +294,7 @@
                 FlowNode flowNode = (FlowNode)treeBuilder.getRegisteredNode("flow");
                 if ( flowNode != null ) {
                     final Interpreter interpreter = flowNode.getInterpreter();
-                    newProcessor.setAttribute(Interpreter.ROLE, interpreter);
+                    concreteTreeProcessor.setAttribute(Interpreter.ROLE, interpreter);
                 }
 
             } finally {
@@ -310,7 +310,7 @@
         }
 
         // Switch to the new processor (ensure it's never temporarily null)
-        this.concreteProcessor = newProcessor;
+        this.concreteProcessor = concreteTreeProcessor;
     }
 
     /**



Mime
View raw message