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 2002/12/04 10:48:41 UTC

cvs commit: xml-cocoon2/src/java/org/apache/cocoon Cocoon.java

cziegeler    2002/12/04 01:48:40

  Modified:    src/java/org/apache/cocoon/serialization XMLSerializer.java
                        LinkSerializer.java HTMLSerializer.java
                        TextSerializer.java AbstractTextSerializer.java
                        AbstractSerializer.java
               src/java/org/apache/cocoon/components/source/impl
                        SitemapSource.java
               src/java/org/apache/cocoon/components
                        CocoonComponentManager.java
               src/java/org/apache/cocoon/sitemap
                        SitemapOutputComponent.java
               src/java/org/apache/cocoon/components/source
                        SitemapSource.java
               src/java/org/apache/cocoon Cocoon.java
  Log:
  Clean up serializer code
  Add cleaning up of environment description
  
  Revision  Changes    Path
  1.10      +8 -16     xml-cocoon2/src/java/org/apache/cocoon/serialization/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/XMLSerializer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XMLSerializer.java	3 Dec 2002 13:30:34 -0000	1.9
  +++ XMLSerializer.java	4 Dec 2002 09:48:40 -0000	1.10
  @@ -68,11 +68,6 @@
   
   public class XMLSerializer extends AbstractTextSerializer {
   
  -    private TransformerHandler handler;
  -
  -    public XMLSerializer() {
  -    }
  -
       /**
        * Set the configurations for this serializer.
        */
  @@ -82,11 +77,15 @@
           this.format.put(OutputKeys.METHOD,"xml");
       }
   
  +    /**
  +     * Set the {@link OutputStream} where the requested resource should
  +     * be serialized.
  +     */
       public void setOutputStream(OutputStream out) throws IOException {
  +        super.setOutputStream(out);
           try {
  -            super.setOutputStream(out);
  -            this.handler = this.getTransformerHandler();
  -            handler.getTransformer().setOutputProperties(format);
  +            TransformerHandler handler = this.getTransformerHandler();
  +            handler.getTransformer().setOutputProperties(this.format);
               handler.setResult(new StreamResult(this.output));
               this.setContentHandler(handler);
               this.setLexicalHandler(handler);
  @@ -96,11 +95,4 @@
           }
       }
   
  -    /**
  -     * Recycle the serializer. GC instance variables
  -     */
  -    public void recycle() {
  -        super.recycle();
  -        this.handler = null;
  -    }
   }
  
  
  
  1.7       +12 -4     xml-cocoon2/src/java/org/apache/cocoon/serialization/LinkSerializer.java
  
  Index: LinkSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/LinkSerializer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LinkSerializer.java	20 Mar 2002 17:00:22 -0000	1.6
  +++ LinkSerializer.java	4 Dec 2002 09:48:40 -0000	1.7
  @@ -50,7 +50,6 @@
   */
   package org.apache.cocoon.serialization;
   
  -import org.apache.avalon.excalibur.pool.Poolable;
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.xml.xlink.ExtendedXLinkPipe;
   import org.xml.sax.Attributes;
  @@ -65,12 +64,14 @@
    * @version CVS $Id$
    */
   
  -public class LinkSerializer extends ExtendedXLinkPipe implements Serializer, Poolable {
  +public class LinkSerializer 
  +    extends ExtendedXLinkPipe 
  +    implements Serializer {
   
       private PrintStream out;
   
       /**
  -     * Set the <code>OutputStream</code> where the requested resource should
  +     * Set the {@link OutputStream} where the requested resource should
        * be serialized.
        */
       public void setOutputStream(OutputStream out) throws IOException {
  @@ -120,4 +121,11 @@
           return false;
       }
   
  +    /**
  +     * Recyclable
  +     */
  +    public void recycle() {
  +        super.recycle();
  +        this.out = null;
  +    }
   }
  
  
  
  1.13      +6 -13     xml-cocoon2/src/java/org/apache/cocoon/serialization/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/HTMLSerializer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HTMLSerializer.java	3 Dec 2002 14:44:12 -0000	1.12
  +++ HTMLSerializer.java	4 Dec 2002 09:48:40 -0000	1.13
  @@ -50,13 +50,12 @@
   */
   package org.apache.cocoon.serialization;
   
  -import javax.xml.transform.OutputKeys;
  -import javax.xml.transform.sax.TransformerHandler;
  -import javax.xml.transform.stream.StreamResult;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.CascadingIOException;
  -
  +import javax.xml.transform.OutputKeys;
  +import javax.xml.transform.sax.TransformerHandler;
  +import javax.xml.transform.stream.StreamResult;
   import java.io.IOException;
   import java.io.OutputStream;
   
  @@ -68,12 +67,6 @@
   public class HTMLSerializer extends AbstractTextSerializer {
   
       /**
  -     * Constructor
  -     */
  -    public HTMLSerializer() {
  -    }
  -
  -    /**
        * Set the configurations for this serializer.
        */
       public void configure(Configuration conf)
  @@ -83,13 +76,13 @@
       }
   
       /**
  -     * Set the <code>OutputStream</code> where the requested resource should
  +     * Set the {@link OutputStream} where the requested resource should
        * be serialized.
        */
       public void setOutputStream(OutputStream out) 
       throws IOException {
  +        super.setOutputStream(out);
           try {
  -            super.setOutputStream(out);
               TransformerHandler handler = this.getTransformerHandler();
               handler.getTransformer().setOutputProperties(this.format);
               handler.setResult(new StreamResult(this.output));
  
  
  
  1.10      +10 -21    xml-cocoon2/src/java/org/apache/cocoon/serialization/TextSerializer.java
  
  Index: TextSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/TextSerializer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TextSerializer.java	3 Dec 2002 13:30:34 -0000	1.9
  +++ TextSerializer.java	4 Dec 2002 09:48:40 -0000	1.10
  @@ -50,14 +50,12 @@
   */
   package org.apache.cocoon.serialization;
   
  -import javax.xml.transform.OutputKeys;
  -import javax.xml.transform.sax.TransformerHandler;
  -import javax.xml.transform.stream.StreamResult;
  -
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.CascadingIOException;
  -
  +import javax.xml.transform.OutputKeys;
  +import javax.xml.transform.sax.TransformerHandler;
  +import javax.xml.transform.stream.StreamResult;
   import java.io.IOException;
   import java.io.OutputStream;
   
  @@ -69,11 +67,6 @@
   
   public class TextSerializer extends AbstractTextSerializer {
   
  -    private TransformerHandler handler;
  -
  -    public TextSerializer() {
  -    }
  -
       /**
        * Set the configurations for this serializer.
        */
  @@ -83,10 +76,14 @@
           this.format.put(OutputKeys.METHOD,"text");
       }
   
  +    /**
  +     * Set the {@link OutputStream} where the requested resource should
  +     * be serialized.
  +     */
       public void setOutputStream(OutputStream out) throws IOException {
  +        super.setOutputStream(out);
           try {
  -            super.setOutputStream(out);
  -            handler = this.getTransformerHandler();
  +            TransformerHandler handler = this.getTransformerHandler();
               handler.getTransformer().setOutputProperties(format);
               handler.setResult(new StreamResult(this.output));
               this.setContentHandler(handler);
  @@ -95,14 +92,6 @@
               final String message = "Cannot set TextSerializer outputstream"; 
               throw new CascadingIOException(message, e);
           }
  -    }
  -
  -    /**
  -     * Recyce the serializer. GC instance variables
  -     */
  -    public void recycle() {
  -        super.recycle();
  -        this.handler = null;
       }
   
   }
  
  
  
  1.18      +8 -9      xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
  
  Index: AbstractTextSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AbstractTextSerializer.java	3 Dec 2002 13:30:34 -0000	1.17
  +++ AbstractTextSerializer.java	4 Dec 2002 09:48:40 -0000	1.18
  @@ -62,24 +62,22 @@
   import org.apache.excalibur.source.impl.validity.NOPValidity;
   import org.xml.sax.Attributes;
   import org.xml.sax.ContentHandler;
  -import org.xml.sax.ext.LexicalHandler;
   import org.xml.sax.SAXException;
  +import org.xml.sax.ext.LexicalHandler;
   import org.xml.sax.helpers.AttributesImpl;
  -
   import javax.xml.transform.OutputKeys;
   import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.sax.SAXTransformerFactory;
   import javax.xml.transform.sax.TransformerHandler;
   import javax.xml.transform.stream.StreamResult;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.StringWriter;
   import java.util.ArrayList;
  +import java.util.HashMap;
   import java.util.List;
   import java.util.Map;
  -import java.util.HashMap;
   import java.util.Properties;
  -import java.io.OutputStream;
  -import java.io.BufferedOutputStream;
  -import java.io.StringWriter;
  -import java.io.IOException;
   
   /**
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
  @@ -184,7 +182,8 @@
       }
   
       /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     * Set the {@link OutputStream} where the requested resource should
  +     * be serialized.
        */
       public void setOutputStream(OutputStream out) 
       throws IOException {
  
  
  
  1.7       +3 -2      xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractSerializer.java
  
  Index: AbstractSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractSerializer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractSerializer.java	23 Aug 2002 09:47:39 -0000	1.6
  +++ AbstractSerializer.java	4 Dec 2002 09:48:40 -0000	1.7
  @@ -70,7 +70,8 @@
       protected OutputStream output;
   
       /**
  -     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     * Set the {@link OutputStream} where the requested resource should
  +     * be serialized.
        */
       public void setOutputStream(OutputStream out) 
       throws IOException {
  
  
  
  1.26      +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- SitemapSource.java	2 Dec 2002 08:39:17 -0000	1.25
  +++ SitemapSource.java	4 Dec 2002 09:48:40 -0000	1.26
  @@ -406,7 +406,7 @@
       private void reset() {
           if (this.processingPipeline != null) this.processingPipeline.release();
           if (this.processKey != null) {
  -            CocoonComponentManager.endProcessing(this.processKey);
  +            CocoonComponentManager.endProcessing(this.environment, this.processKey);
               this.processKey = null;
           }
           this.processingPipeline = null;
  
  
  
  1.44      +10 -4     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.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- CocoonComponentManager.java	3 Dec 2002 10:21:57 -0000	1.43
  +++ CocoonComponentManager.java	4 Dec 2002 09:48:40 -0000	1.44
  @@ -180,11 +180,12 @@
        * @param key A unique key within this thread return by
        *         {@link startProcessing(Environment)}.
        */
  -    public static void endProcessing(Object key) {
  +    public static void endProcessing(Environment env, Object key) {
           EnvironmentDescription desc = (EnvironmentDescription)key;
           desc.release();
  +        env.getObjectModel().remove(PROCESS_KEY);
       }
  -    
  +
       /**
        * Return the current environment (for the cocoon: protocol)
        */
  @@ -469,6 +470,11 @@
                   }
               }
           }
  +        this.requestLifecycleComponents.clear();
  +        this.autoreleaseComponents.clear();
  +        this.sitemapConfigurations.clear();
  +        this.environment = null;
  +        this.objectModel = null;
       }
     
   
  @@ -545,7 +551,7 @@
             
       void addSitemapConfiguration(Configuration conf) {
           if (conf != null) {
  -             this.sitemapConfigurations.add(conf);
  +            this.sitemapConfigurations.add(conf);
           } else {
               this.sitemapConfigurations.add(EMPTY_CONFIGURATION);
           }
  
  
  
  1.5       +3 -2      xml-cocoon2/src/java/org/apache/cocoon/sitemap/SitemapOutputComponent.java
  
  Index: SitemapOutputComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/sitemap/SitemapOutputComponent.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SitemapOutputComponent.java	22 Feb 2002 07:03:55 -0000	1.4
  +++ SitemapOutputComponent.java	4 Dec 2002 09:48:40 -0000	1.5
  @@ -62,8 +62,9 @@
    * @version CVS $Id$
    */
   public interface SitemapOutputComponent extends Component {
  +
       /**
  -     * Set the <code>OutputStream</code> where the requested resource should
  +     * Set the {@link OutputStream} where the requested resource should
        * be serialized.
        */
       void setOutputStream(OutputStream out) throws IOException;
  
  
  
  1.24      +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- SitemapSource.java	20 Nov 2002 10:35:52 -0000	1.23
  +++ SitemapSource.java	4 Dec 2002 09:48:40 -0000	1.24
  @@ -368,7 +368,7 @@
       private void reset() {
           if (this.processingPipeline != null) this.processingPipeline.release();
           if (this.processKey != null) {
  -            CocoonComponentManager.endProcessing(this.processKey);
  +            CocoonComponentManager.endProcessing(this.environment, this.processKey);
               this.processKey = null;
           }
           this.processingPipeline = null;
  
  
  
  1.43      +2 -2      xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Cocoon.java	14 Nov 2002 15:43:32 -0000	1.42
  +++ Cocoon.java	4 Dec 2002 09:48:40 -0000	1.43
  @@ -611,7 +611,7 @@
               environment.tryResetResponse();
               throw any;
           } finally {
  -            CocoonComponentManager.endProcessing(key);
  +            CocoonComponentManager.endProcessing(environment, key);
               if (this.getLogger().isDebugEnabled()) {
                   --activeRequestCount;
               }
  
  
  

----------------------------------------------------------------------
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