You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/01/08 12:13:07 UTC

cvs commit: cocoon-2.2/src/java/org/apache/cocoon/components/pipeline ProcessingPipeline.java AbstractProcessingPipeline.java

cziegeler    2004/01/08 03:13:07

  Modified:    src/java/org/apache/cocoon/components/source/impl
                        SitemapSource.java
               src/java/org/apache/cocoon/components/cprocessor
                        InvokeContext.java TreeProcessor.java
               src/java/org/apache/cocoon ProcessorWrapper.java Cocoon.java
                        Processor.java
               src/java/org/apache/cocoon/components/pipeline
                        ProcessingPipeline.java
                        AbstractProcessingPipeline.java
  Log:
  Automatic release for pipelines
  
  Revision  Changes    Path
  1.21      +5 -3      cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- SitemapSource.java	6 Jan 2004 12:49:26 -0000	1.20
  +++ SitemapSource.java	8 Jan 2004 11:13:07 -0000	1.21
  @@ -409,12 +409,14 @@
        * Reset everything
        */
       private void reset() {
  -        if (this.processingPipeline != null) this.processingPipeline.release();
  +        if (this.processingPipeline != null) {
  +            this.processor.releasePipeline(this.processingPipeline);
  +            this.processingPipeline = null;
  +        }
           if (this.processKey != null) {
               EnvironmentHelper.endProcessing(this.environment, this.processKey);
               this.processKey = null;
           }
  -        this.processingPipeline = null;
           this.sourceValidity = null;
           if (this.redirectSource != null) {
               this.sourceResolver.release(this.redirectSource);
  
  
  
  1.3       +4 -5      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/InvokeContext.java
  
  Index: InvokeContext.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/InvokeContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InvokeContext.java	5 Jan 2004 08:16:00 -0000	1.2
  +++ InvokeContext.java	8 Jan 2004 11:13:07 -0000	1.3
  @@ -62,6 +62,7 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
  +import org.apache.cocoon.components.container.CocoonComponentManager;
   import org.apache.cocoon.components.cprocessor.variables.VariableResolver;
   
   /**
  @@ -173,10 +174,8 @@
                                                      this, this.processingPipelineObjectModel)
               );
               if (this.isBuildingPipelineOnly) {
  -// TODO: where does this go, RequestLifecycleHelper?
  -//                CocoonComponentManager.addComponentForAutomaticRelease(this.pipelineSelector,
  -//                                                                       this.processingPipeline,
  -//                                                                       this.pipelinesManager);
  +                CocoonComponentManager.addComponentForAutomaticRelease(this.pipelinesManager,
  +                                                                       this.processingPipeline);
               }
           }
           return this.processingPipeline;
  
  
  
  1.11      +18 -0     cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java
  
  Index: TreeProcessor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TreeProcessor.java	7 Jan 2004 15:41:38 -0000	1.10
  +++ TreeProcessor.java	8 Jan 2004 11:13:07 -0000	1.11
  @@ -77,8 +77,10 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.cocoon.Constants;
  +import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Processor;
   import org.apache.cocoon.components.ChainedConfiguration;
  +import org.apache.cocoon.components.container.CocoonComponentManager;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
   import org.apache.cocoon.components.sax.XMLTeePipe;
   import org.apache.cocoon.components.source.SourceUtil;
  @@ -531,8 +533,24 @@
           return result;
       }
       
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#getEnvironmentHelper()
  +     */
       public EnvironmentHelper getEnvironmentHelper() {
           return m_environmentHelper;
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#releasePipeline(org.apache.cocoon.components.pipeline.ProcessingPipeline)
  +     */
  +    public void releasePipeline(ProcessingPipeline pipeline) {
  +        // TODO
  +        try {
  +            CocoonComponentManager.removeFromAutomaticRelease(pipeline);
  +        } catch (ProcessingException pe) {
  +            // ignore this
  +            getLogger().error("Unabled to release processing component.", pe);
  +        }
       }
   
       /**
  
  
  
  1.8       +25 -19    cocoon-2.2/src/java/org/apache/cocoon/ProcessorWrapper.java
  
  Index: ProcessorWrapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/ProcessorWrapper.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProcessorWrapper.java	30 Oct 2003 12:20:45 -0000	1.7
  +++ ProcessorWrapper.java	8 Jan 2004 11:13:07 -0000	1.8
  @@ -53,7 +53,6 @@
   import java.util.Map;
   
   import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
   import org.apache.cocoon.environment.Environment;
  @@ -62,51 +61,58 @@
   /**
    * This class is a wrapper around the real processor (the <code>Cocoon</code> class).
    * It is necessary to avoid infinite dispose loops
  + * 
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @version CVS $Id$
    */
   public final class ProcessorWrapper
  -implements Processor, Component, Disposable, ThreadSafe {
  +implements Processor, Disposable, ThreadSafe {
   
       private Processor processor;
   
  -    public void dispose() {
  -        this.processor = null;
  -    }
  -
       public ProcessorWrapper(Processor processor) {
           this.processor = processor;
       }
   
  -    /**
  -     * Process the given <code>Environment</code> producing the output
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.activity.Disposable#dispose()
  +     */
  +    public void dispose() {
  +        this.processor = null;
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#process(org.apache.cocoon.environment.Environment)
        */
       public boolean process(Environment environment)
       throws Exception {
           return this.processor.process(environment);
       }
   
  -    /**
  -     * Process the given <code>Environment</code> to assemble
  -     * a <code>ProcessingPipeline</code>.
  -     * @since 2.1
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#buildPipeline(org.apache.cocoon.environment.Environment)
        */
       public ProcessingPipeline buildPipeline(Environment environment)
       throws Exception {
           return this.processor.buildPipeline(environment);
       }
   
  -    /**
  -     * Get the sitemap component configurations
  -     * @since 2.1
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#releasePipeline(org.apache.cocoon.components.pipeline.ProcessingPipeline)
  +     */
  +    public void releasePipeline(ProcessingPipeline pipeline) {
  +        this.processor.releasePipeline(pipeline);
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#getComponentConfigurations()
        */
       public Map getComponentConfigurations() {
           return this.processor.getComponentConfigurations();
       }
       
  -    /**
  -     * Get the root parent processor of this processor
  -     * @since 2.1.1
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#getRootProcessor()
        */
       public Processor getRootProcessor() {
           return this.processor.getRootProcessor();
  
  
  
  1.33      +15 -1     cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Cocoon.java	5 Jan 2004 08:16:01 -0000	1.32
  +++ Cocoon.java	8 Jan 2004 11:13:07 -0000	1.33
  @@ -68,6 +68,7 @@
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.cocoon.components.container.CocoonComponentManager;
   import org.apache.cocoon.components.language.generator.ProgramGenerator;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
   import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
  @@ -523,5 +524,18 @@
           return this.environmentHelper.getContext();
       }
   
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.Processor#releasePipeline(org.apache.cocoon.components.pipeline.ProcessingPipeline)
  +     */
  +    public void releasePipeline(ProcessingPipeline pipeline) {
  +        // TODO
  +        try {
  +            CocoonComponentManager.removeFromAutomaticRelease(pipeline);
  +        } catch (ProcessingException pe) {
  +            // ignore this
  +            getLogger().error("Unabled to release processing component.", pe);
  +        }
  +    }
  +    
   }
   
  
  
  
  1.12      +8 -1      cocoon-2.2/src/java/org/apache/cocoon/Processor.java
  
  Index: Processor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/Processor.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Processor.java	6 Dec 2003 21:22:10 -0000	1.11
  +++ Processor.java	8 Jan 2004 11:13:07 -0000	1.12
  @@ -83,11 +83,18 @@
       /**
        * Process the given <code>Environment</code> to assemble
        * a <code>ProcessingPipeline</code>.
  +     * Don't forget to release the pipeline using
  +     * {@link releasePipeline(ProcessingPipeline)}.
        * @since 2.1
        */
       ProcessingPipeline buildPipeline(Environment environment)
       throws Exception;
   
  +    /**
  +     * Release the pipeline delivered by {@link buildPipeline(Environment)}
  +     */
  +    void releasePipeline(ProcessingPipeline pipeline);
  +    
       /**
        * Get the sitemap component configurations
        * @since 2.1
  
  
  
  1.6       +1 -9      cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
  
  Index: ProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ProcessingPipeline.java	5 Nov 2003 21:29:08 -0000	1.5
  +++ ProcessingPipeline.java	8 Jan 2004 11:13:07 -0000	1.6
  @@ -98,14 +98,6 @@
       void setup(Parameters params);
   
       /**
  -     * Release this component
  -     * If you get an instance not by a component manager but for example
  -     * by a processor, you have to release this component by calling
  -     * this method and NOT by using a component manager!
  -     */
  -    void release();
  -
  -    /**
        * Set the generator that will be used as the initial step in the pipeline.
        * The generator role is given : the actual <code>Generator</code> is fetched
        * from the latest <code>ComponentManager</code> given by <code>compose()</code>
  
  
  
  1.24      +1 -17     cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
  
  Index: AbstractProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- AbstractProcessingPipeline.java	7 Jan 2004 15:57:30 -0000	1.23
  +++ AbstractProcessingPipeline.java	8 Jan 2004 11:13:07 -0000	1.24
  @@ -69,7 +69,6 @@
   import org.apache.cocoon.ConnectionResetException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Processor;
  -import org.apache.cocoon.components.container.CocoonComponentManager;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.EnvironmentHelper;
   import org.apache.cocoon.environment.ObjectModelHelper;
  @@ -192,21 +191,6 @@
           }
           this.outputBufferSize = params.getParameterAsInteger("outputBufferSize",
                                                                 this.configuredOutputBufferSize);
  -    }
  -
  -    /**
  -     * Release this component
  -     * If you get an instance not by a component manager but for example
  -     * by a processor, you have to release this component by calling
  -     * this method and NOT by using a component manager!
  -     */
  -    public void release() {
  -        try {
  -            CocoonComponentManager.removeFromAutomaticRelease(this);
  -        } catch (ProcessingException pe) {
  -            // ignore this
  -            getLogger().error("Unabled to release processing component.", pe);
  -        }
       }
   
       /**