cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r619496 - in /cocoon/whiteboard/micro/core: cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/components/pipeline/ cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/ cocoon-sitemap/co...
Date Thu, 07 Feb 2008 16:43:16 GMT
Author: reinhard
Date: Thu Feb  7 08:43:06 2008
New Revision: 619496

URL: http://svn.apache.org/viewvc?rev=619496&view=rev
Log:
cleanup the usage of the service manager because there is no need to maintain two separate
instances because one instance per sitemap servlet is enough

Modified:
    cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
    cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/Processor.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java

Modified: cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java?rev=619496&r1=619495&r2=619496&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
Thu Feb  7 08:43:06 2008
@@ -17,14 +17,11 @@
 package org.apache.cocoon.components.pipeline;
 
 import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceManager;
-
 import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.sitemap.SitemapErrorHandler;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.generation.Generator;
+import org.apache.cocoon.sitemap.SitemapErrorHandler;
 import org.apache.cocoon.xml.XMLConsumer;
-
 import org.apache.excalibur.source.SourceValidity;
 
 /**
@@ -73,12 +70,6 @@
      * Informs pipeline we have come across a branch point
      */
     void informBranchPoint();
-
-    /**
-     * Set the <code>ServiceManager</code> where pipeline components have to
be searched for.
-     * @param manager the processor's service manager.
-     */
-    void setProcessorManager(ServiceManager manager);
 
     /**
      * Add a transformer at the end of the pipeline.

Modified: cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java?rev=619496&r1=619495&r2=619496&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Thu Feb  7 08:43:06 2008
@@ -25,6 +25,7 @@
 import java.util.StringTokenizer;
 
 import org.apache.avalon.excalibur.pool.Recyclable;
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
 import org.apache.avalon.framework.parameters.Parameters;
@@ -63,9 +64,8 @@
  * @since 2.1
  * @version $Id$
  */
-public abstract class AbstractProcessingPipeline extends AbstractLogEnabled
-                                                 implements ProcessingPipeline, Parameterizable,
-                                                            Recyclable, Serviceable {
+public abstract class AbstractProcessingPipeline extends AbstractLogEnabled implements ProcessingPipeline,
+        Parameterizable, Recyclable, Disposable, Serviceable {
 
     // Generator stuff
     protected Generator generator;
@@ -105,9 +105,6 @@
     /** The component manager set with compose() */
     protected ServiceManager manager;
 
-    /** The component manager set with compose() and recompose() */
-    protected ServiceManager newManager;
-
     /** The configuration */
     protected Parameters configuration;
 
@@ -132,17 +129,9 @@
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
-    public void service (ServiceManager aManager)
-    throws ServiceException {
-        this.manager = aManager;
-        this.newManager = aManager;
-    }
-
-    /**
-     * Set the processor's service manager
-     */
-    public void setProcessorManager (ServiceManager manager) {
-        this.newManager = manager;
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+        this.sourceResolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
     }
 
     /**
@@ -210,7 +199,7 @@
                     getLocation(param));
         }
         try {
-            this.generator = (Generator) this.newManager.lookup(Generator.ROLE + '/' + role);
+            this.generator = (Generator) this.manager.lookup(Generator.ROLE + '/' + role);
         } catch (ServiceException ce) {
             throw ProcessingException.throwLocated("Lookup of generator '" + role + "' failed",
ce, getLocation(param));
         }
@@ -241,7 +230,7 @@
                     getLocation(param));
         }
         try {
-            this.transformers.add(this.newManager.lookup(Transformer.ROLE + '/' + role));
+            this.transformers.add(this.manager.lookup(Transformer.ROLE + '/' + role));
         } catch (ServiceException ce) {
             throw ProcessingException.throwLocated("Lookup of transformer '"+role+"' failed",
ce, getLocation(param));
         }
@@ -271,7 +260,7 @@
         }
 
         try {
-            this.serializer = (Serializer)this.newManager.lookup(Serializer.ROLE + '/' +
role);
+            this.serializer = (Serializer) this.manager.lookup(Serializer.ROLE + '/' + role);
         } catch (ServiceException ce) {
             throw ProcessingException.throwLocated("Lookup of serializer '" + role + "' failed",
ce, getLocation(param));
         }
@@ -299,7 +288,7 @@
         }
 
         try {
-            this.reader = (Reader)this.newManager.lookup(Reader.ROLE + '/' + role);
+            this.reader = (Reader) this.manager.lookup(Reader.ROLE + '/' + role);
         } catch (ServiceException ce) {
             throw ProcessingException.throwLocated("Lookup of reader '"+role+"' failed",
ce, getLocation(param));
         }
@@ -443,15 +432,7 @@
     /**
      * Prepare the pipeline
      */
-    protected void preparePipeline(Environment environment)
-    throws ProcessingException {
-        // Look up the source resolver as late as possible as setProcessorManager might
-        // have changed the service manager
-        try {
-            this.sourceResolver = (SourceResolver) this.newManager.lookup(SourceResolver.ROLE);
-        } catch (ServiceException e) {
-            throw new ProcessingException("Couldn't find a source resolver", e);
-        }
+    protected void preparePipeline(Environment environment) throws ProcessingException {
         if (!checkPipeline()) {
             throw new ProcessingException("Attempted to process incomplete pipeline.");
         }
@@ -673,7 +654,7 @@
             if ( this.reader instanceof DisposableSitemapComponent ) {
                 ((DisposableSitemapComponent)this.reader).dispose();
             }
-            this.newManager.release(this.reader);
+            this.manager.release(this.reader);
             this.reader = null;
             this.readerParam = null;
         }
@@ -683,7 +664,7 @@
             if ( this.generator instanceof DisposableSitemapComponent ) {
                 ((DisposableSitemapComponent)this.generator).dispose();
             }
-            this.newManager.release(this.generator);
+            this.manager.release(this.generator);
             this.generator = null;
             this.generatorParam = null;
         }
@@ -694,7 +675,7 @@
             if ( this.transformers.get(i) instanceof DisposableSitemapComponent ) {
                 ((DisposableSitemapComponent)this.transformers.get(i)).dispose();
             }
-            this.newManager.release(this.transformers.get(i));
+            this.manager.release(this.transformers.get(i));
         }
         this.transformers.clear();
         this.transformerParams.clear();
@@ -705,17 +686,12 @@
             if ( this.serializer instanceof DisposableSitemapComponent ) {
                 ((DisposableSitemapComponent)this.serializer).dispose();
             }
-            this.newManager.release(this.serializer);
+            this.manager.release(this.serializer);
             this.serializerParam = null;
         }
 
-        // Release source resolver
-        if (this.sourceResolver != null) {
-            this.newManager.release(this.sourceResolver);
-        }
         this.serializer = null;
         this.parameters = null;
-        this.sourceResolver = null;
         this.lastConsumer = null;
 
         // Release error handler
@@ -725,6 +701,14 @@
         // This is not done by using release in the creating container as release
         // is a noop for the Avalon life style in the Spring container
         this.errorPipeline = null;
+    }
+
+    public void dispose() {
+        // Release source resolver
+        if (this.sourceResolver != null) {
+            this.manager.release(this.sourceResolver);
+        }
+        this.sourceResolver = null;
     }
 
     /**

Modified: cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/Processor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/Processor.java?rev=619496&r1=619495&r2=619496&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/Processor.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-api/src/main/java/org/apache/cocoon/Processor.java
Thu Feb  7 08:43:06 2008
@@ -49,33 +49,23 @@
         /** Environment URI */
         public String uri;
 
-        public InternalPipelineDescription(Processor processor,
-                                           ServiceManager manager,
-                                           ProcessingPipeline pipeline) {
+        public InternalPipelineDescription(Processor processor, ProcessingPipeline pipeline)
{
             this.processor = processor;
-            this.pipelineManager = manager;
             this.processingPipeline = pipeline;
         }
 
-        public void release() {
-            if (this.pipelineManager != null) {
-                this.pipelineManager.release(this.processingPipeline);
-            }
-            this.processingPipeline = null;
-            this.pipelineManager = null;
-            this.processor = null;
-        }
     }
 
     /**
      * Process the given <code>Environment</code> producing the output.
+     *
      * @return If the processing is successfull <code>true</code> is returned.
-     *         If no match is found in the sitemap <code>false</code>
-     *         is returned.
-     * @throws ResourceNotFoundException If a sitemap component tries
-     *                                   to access a resource which can not
-     *                                   be found, e.g. the generator
-     *         ConnectionResetException  If the connection was reset
+     *         If no match is found in the sitemap <code>false</code> is
+     *         returned.
+     * @throws ResourceNotFoundException
+     *             If a sitemap component tries to access a resource which can
+     *             not be found, e.g. the generator ConnectionResetException If
+     *             the connection was reset
      */
     boolean process(Environment environment) throws Exception;
 

Modified: cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java?rev=619496&r1=619495&r2=619496&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
Thu Feb  7 08:43:06 2008
@@ -60,7 +60,7 @@
     protected Redirector redirector;
 
     /** The current component manager, as set by the last call to {@link #service}. */
-    private ServiceManager currentManager;
+    private ServiceManager manager;
 
     /** Unified Object Model */
     private ObjectModel newObjectModel;
@@ -71,9 +71,6 @@
     /** The error handler for the pipeline. */
     protected SitemapErrorHandler errorHandler;
 
-    /** The component manager that was used to get the pipelines */
-    private ServiceManager pipelinesManager;
-
     /** The name of the processing pipeline component */
     protected String processingPipelineType;
 
@@ -108,10 +105,7 @@
      * Serviceable interface. InvokeContext receives manager from {@link ConcreteTreeProcessor}.
      */
     public void service(ServiceManager manager) throws ServiceException {
-        this.currentManager = manager;
-        if (this.processingPipeline != null) {
-            this.processingPipeline.setProcessorManager(manager);
-        }
+        this.manager = manager;
         this.newObjectModel = (ObjectModel) manager.lookup(ObjectModel.ROLE);
     }
 
@@ -177,11 +171,7 @@
     public ProcessingPipeline getProcessingPipeline()
     throws Exception {
         if (this.processingPipeline == null) {
-            // Keep current manager for proper release
-            this.pipelinesManager = this.currentManager;
-
-            this.processingPipeline = (ProcessingPipeline) this.pipelinesManager.lookup(ProcessingPipeline.ROLE
+ '/' + this.processingPipelineType);
-            this.processingPipeline.setProcessorManager(this.pipelinesManager);
+            this.processingPipeline = (ProcessingPipeline) this.manager.lookup(ProcessingPipeline.ROLE
+ '/' + this.processingPipelineType);
 
             this.processingPipeline.setup(this.processingPipelineParameters);
             this.processingPipeline.setErrorHandler(this.errorHandler);
@@ -195,9 +185,8 @@
      */
     public void setInternalPipelineDescription(Processor.InternalPipelineDescription desc)
{
         this.processingPipeline = desc.processingPipeline;
-        this.pipelinesManager = desc.pipelineManager;
         this.lastProcessor = desc.processor;
-        this.internalPipelineDescription = new Processor.InternalPipelineDescription(this.lastProcessor,
this.pipelinesManager, this.processingPipeline);
+        this.internalPipelineDescription = new Processor.InternalPipelineDescription(this.lastProcessor,
this.processingPipeline);
         this.internalPipelineDescription.prefix = desc.prefix;
         this.internalPipelineDescription.uri = desc.uri;
     }
@@ -207,7 +196,7 @@
      */
     public Processor.InternalPipelineDescription getInternalPipelineDescription(Environment
env) {
         if (this.internalPipelineDescription == null) {
-            this.internalPipelineDescription = new Processor.InternalPipelineDescription(this.lastProcessor,
this.pipelinesManager, this.processingPipeline);
+            this.internalPipelineDescription = new Processor.InternalPipelineDescription(this.lastProcessor,
this.processingPipeline);
             this.internalPipelineDescription.prefix = env.getURIPrefix();
             this.internalPipelineDescription.uri = env.getURI();
         }
@@ -313,22 +302,21 @@
      * Release the pipelines, if any, if they were looked up by this context.
      */
     public void dispose() {
-        if (this.internalPipelineDescription == null && this.pipelinesManager !=
null) {
+        if (this.internalPipelineDescription == null && manager != null) {
             if (this.processingPipeline != null) {
-                this.pipelinesManager.release(this.processingPipeline);
+                manager.release(this.processingPipeline);
                 this.processingPipeline = null;
             }
-            this.pipelinesManager = null;
 
             this.processingPipelineType = null;
             this.processingPipelineParameters = null;
         }
 
         if (this.newObjectModel != null) {
-            this.currentManager.release(this.newObjectModel);
+            this.manager.release(this.newObjectModel);
             this.newObjectModel = null;
         }
 
-        this.currentManager = null;
+        this.manager = null;
     }
 }



Mime
View raw message