cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor InvokeContext.java
Date Wed, 29 May 2002 09:12:05 GMT
cziegeler    02/05/29 02:12:04

  Modified:    .        todo.xml
               src/java/org/apache/cocoon/components
                        CocoonComponentManager.java
               src/java/org/apache/cocoon/components/pipeline
                        AbstractProcessingPipeline.java
               src/java/org/apache/cocoon/components/treeprocessor
                        InvokeContext.java
  Log:
  Fixed documentation generation
  Fixed out of memory error
  Corrected release of ProcessingPipeline
  
  Revision  Changes    Path
  1.35      +1 -7      xml-cocoon2/todo.xml
  
  Index: todo.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/todo.xml,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- todo.xml	29 May 2002 08:20:25 -0000	1.34
  +++ todo.xml	29 May 2002 09:12:04 -0000	1.35
  @@ -3,7 +3,7 @@
   <!DOCTYPE todo PUBLIC "-//APACHE//DTD Todo V1.0//EN" "src/documentation/xdocs/dtd/todo-v10.dtd">
   
   <!--
  -  $Id: todo.xml,v 1.34 2002/05/29 08:20:25 cziegeler Exp $
  +  $Id: todo.xml,v 1.35 2002/05/29 09:12:04 cziegeler Exp $
   -->
   
   
  @@ -34,12 +34,6 @@
      a correct implementation of the toString() method of the used
      keys. A correct version should rely on hashCode() and equals().
      (This is actually an Avalon action as the code is in Excalibur)
  -  </action> 
  -
  -  <action context="code" assigned-to="open">
  -    Correct the release of internal ProcessingPipelines. If an
  -    error/exception occurs, the ProcessingPipeline might not be
  -    released correctly.
     </action> 
   
     <action context="code" assigned-to="open">
  
  
  
  1.19      +89 -2     xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- CocoonComponentManager.java	26 Apr 2002 08:41:52 -0000	1.18
  +++ CocoonComponentManager.java	29 May 2002 09:12:04 -0000	1.19
  @@ -51,14 +51,17 @@
   package org.apache.cocoon.components;
   
   import java.io.IOException;
  +import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.List;
   import java.util.Map;
   import java.util.Stack;
   import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.ComponentSelector;
   import org.apache.avalon.framework.component.Recomposable;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.environment.Environment;
  @@ -76,7 +79,7 @@
    * and by handling the lookup of the <code>SourceResolver</code> (in development)
    *
    * @author <a href="mailto:cziegeler@org.com">Carsten Ziegeler</a>
  - * @version CVS $Id: CocoonComponentManager.java,v 1.18 2002/04/26 08:41:52 cziegeler Exp
$
  + * @version CVS $Id: CocoonComponentManager.java,v 1.19 2002/05/29 09:12:04 cziegeler Exp
$
    */
   public final class CocoonComponentManager
   extends ExcaliburComponentManager
  @@ -132,7 +135,7 @@
                   return;
               }
           }
  -        stack.push(new Object[] {env, objectModel, new HashMap(5), ONE, processor});
  +        stack.push(new Object[] {env, objectModel, new HashMap(5), ONE, processor, new
ArrayList(2)});
       }
   
       /**
  @@ -150,6 +153,21 @@
                       final Component component = (Component)o[0];
                       ((CocoonComponentManager)o[1]).releaseRLComponent( component );
                   }
  +                if (objects.length > 5) {
  +                    final List automaticReleasedComponents = (List)objects[5];
  +                    for(int i = 0; i < automaticReleasedComponents.size(); i++) {
  +                        final Object[] o = (Object[])automaticReleasedComponents.get(i);
  +                        final Component component = (Component)o[0];
  +                        if (o[1] instanceof ComponentManager) {
  +                            ((ComponentManager)o[1]).release( component );
  +                        } else {
  +                            ((ComponentSelector)o[1]).release( component );
  +                            if (o[2] != null) {
  +                                ((ComponentManager)o[2]).release( (Component)o[1] );
  +                            }
  +                        }
  +                    }
  +                }
               }
           }
       }
  @@ -232,6 +250,75 @@
               return;
           }
           super.release( component);
  +    }
  +
  +    /**
  +     * Add an automatically released component
  +     */
  +    public static void addComponentForAutomaticRelease(final ComponentSelector selector,
  +                                                       final Component         component,
  +                                                       final ComponentManager  manager)
  +    throws ProcessingException {
  +        final Stack stack = (Stack)environmentStack.get();
  +        if ( null != stack && !stack.empty()) {
  +            final Object[] objects = (Object[])stack.firstElement();
  +            final List automaticReleasedComponents = (List)objects[5];
  +            automaticReleasedComponents.add(new Object[] {component, selector, manager});
  +        } else {
  +            throw new ProcessingException("Unable to add component for automatic release:
no environment available.");
  +        }
  +    }
  +
  +    /**
  +     * Add an automatically released component
  +     */
  +    public static void addComponentForAutomaticRelease(final ComponentManager manager,
  +                                                       final Component        component)
  +    throws ProcessingException {
  +        final Stack stack = (Stack)environmentStack.get();
  +        if ( null != stack && !stack.empty()) {
  +            final Object[] objects = (Object[])stack.firstElement();
  +            final List automaticReleasedComponents = (List)objects[5];
  +            automaticReleasedComponents.add(new Object[] {component, manager});
  +        } else {
  +            throw new ProcessingException("Unable to add component for automatic release:
no environment available.");
  +        }
  +    }
  +
  +    /**
  +     * Remove from automatically released components
  +     */
  +    public static void removeFromAutomaticRelease(final Component component)
  +    throws ProcessingException {
  +        final Stack stack = (Stack)environmentStack.get();
  +        if ( null != stack && !stack.empty()) {
  +            final Object[] objects = (Object[])stack.firstElement();
  +            final List automaticReleasedComponents = (List)objects[5];
  +            int i = 0;
  +            boolean found = false;
  +            while (i < automaticReleasedComponents.size() && !found) {
  +                final Object[] o = (Object[])automaticReleasedComponents.get(i);
  +                if (o[0] == component) {
  +                    found = true;
  +                    if (o[1] instanceof ComponentManager) {
  +                        ((ComponentManager)o[1]).release( component );
  +                    } else {
  +                        ((ComponentSelector)o[1]).release( component );
  +                        if (o[2] != null) {
  +                            ((ComponentManager)o[2]).release( (Component)o[1] );
  +                        }
  +                    }
  +                    automaticReleasedComponents.remove(i);
  +                } else {
  +                    i++;
  +                }
  +            }
  +            if (!found) {
  +                throw new ProcessingException("Unable to remove component from automatic
release: component not found.");
  +            }
  +        } else {
  +            throw new ProcessingException("Unable to remove component from automatic release:
no environment available.");
  +        }
       }
   
       /**
  
  
  
  1.15      +8 -2      xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
  
  Index: AbstractProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractProcessingPipeline.java	29 May 2002 08:20:26 -0000	1.14
  +++ AbstractProcessingPipeline.java	29 May 2002 09:12:04 -0000	1.15
  @@ -61,6 +61,7 @@
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.cocoon.ConnectionResetException;
   import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.pipeline.OutputComponentSelector;
   import org.apache.cocoon.components.saxconnector.SAXConnector;
   import org.apache.cocoon.environment.Environment;
  @@ -84,7 +85,7 @@
    *
    * @since @next-version@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Id: AbstractProcessingPipeline.java,v 1.14 2002/05/29 08:20:26 cziegeler
Exp $
  + * @version CVS $Id: AbstractProcessingPipeline.java,v 1.15 2002/05/29 09:12:04 cziegeler
Exp $
    */
   public abstract class AbstractProcessingPipeline
     extends AbstractLogEnabled
  @@ -196,7 +197,12 @@
        * this method and NOT by using a component manager!
        */
       public void release() {
  -        this.manager.release( this );
  +        try {
  +            CocoonComponentManager.removeFromAutomaticRelease( this );
  +        } catch (ProcessingException pe) {
  +            // ignore this
  +            this.getLogger().error("Unabled to release processing component.", pe);
  +        }
       }
   
       /**
  
  
  
  1.10      +7 -2      xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java
  
  Index: InvokeContext.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/InvokeContext.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- InvokeContext.java	27 May 2002 14:31:27 -0000	1.9
  +++ InvokeContext.java	29 May 2002 09:12:04 -0000	1.10
  @@ -57,7 +57,7 @@
   import org.apache.avalon.framework.component.ComponentSelector;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.avalon.framework.logger.Loggable;
  -
  +import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
   import org.apache.cocoon.environment.Environment;
   import org.apache.log.Logger;
  @@ -76,7 +76,7 @@
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Id: InvokeContext.java,v 1.9 2002/05/27 14:31:27 cziegeler Exp $
  + * @version CVS $Id: InvokeContext.java,v 1.10 2002/05/29 09:12:04 cziegeler Exp $
    */
   
   public class InvokeContext implements Recomposable, Disposable, Loggable {
  @@ -172,6 +172,11 @@
                     MapStackResolver.buildParameters(this.processingPipelineParameters,
                                                      this.getMapStack())
               );
  +            if (this.isInternalRequest) {
  +                CocoonComponentManager.addComponentForAutomaticRelease(this.pipelineSelector,
  +                                                                       this.processingPipeline,
  +                                                                       this.pipelinesManager);
  +            }
           }
           return this.processingPipeline;
       }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message