cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morr...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/serialization AbstractSerializer.java AbstractTextSerializer.java HTMLSerializer.java TextSerializer.java XMLSerializer.java
Date Thu, 01 Nov 2001 09:44:33 GMT
morrijr     01/11/01 01:44:33

  Modified:    src/org/apache/cocoon/serialization Tag: cocoon_20_branch
                        AbstractSerializer.java AbstractTextSerializer.java
                        HTMLSerializer.java TextSerializer.java
                        XMLSerializer.java
  Log:
  Patch from Joerg Henne wrt buffering.  Patch from Jorn Heid also applied
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.5   +2 -3      xml-cocoon2/src/org/apache/cocoon/serialization/AbstractSerializer.java
  
  Index: AbstractSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/serialization/AbstractSerializer.java,v
  retrieving revision 1.2.2.4
  retrieving revision 1.2.2.5
  diff -u -r1.2.2.4 -r1.2.2.5
  --- AbstractSerializer.java	2001/10/11 08:56:14	1.2.2.4
  +++ AbstractSerializer.java	2001/11/01 09:44:33	1.2.2.5
  @@ -11,14 +11,13 @@
   import org.apache.avalon.excalibur.pool.Recyclable;
   import org.apache.cocoon.xml.AbstractXMLPipe;
   
  -import java.io.BufferedOutputStream;
   import java.io.OutputStream;
   
   /**
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.2.2.4 $ $Date: 2001/10/11 08:56:14 $
  + * @version CVS $Revision: 1.2.2.5 $ $Date: 2001/11/01 09:44:33 $
    */
   
   public abstract class AbstractSerializer extends AbstractXMLPipe implements Serializer,
Recyclable {
  @@ -32,7 +31,7 @@
        * Set the <code>OutputStream</code> where the XML should be serialized.
        */
       public void setOutputStream(OutputStream out) {
  -        this.output = new BufferedOutputStream(out);
  +        this.output = out;
       }
   
       /**
  
  
  
  1.2.2.7   +38 -2     xml-cocoon2/src/org/apache/cocoon/serialization/AbstractTextSerializer.java
  
  Index: AbstractTextSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/serialization/AbstractTextSerializer.java,v
  retrieving revision 1.2.2.6
  retrieving revision 1.2.2.7
  diff -u -r1.2.2.6 -r1.2.2.7
  --- AbstractTextSerializer.java	2001/10/11 08:56:14	1.2.2.6
  +++ AbstractTextSerializer.java	2001/11/01 09:44:33	1.2.2.7
  @@ -24,14 +24,20 @@
   import javax.xml.transform.OutputKeys;
   import javax.xml.transform.TransformerFactory;
   import javax.xml.transform.sax.SAXTransformerFactory;
  -import java.util.*;
  +import java.util.ArrayList;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.HashMap;
  +import java.util.Properties;
  +import java.io.OutputStream;
  +import java.io.BufferedOutputStream;
   
   /**
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:sylvain.wallez@anyware-tech.com">Sylvain Wallez</a>
  - * @version CVS $Revision: 1.2.2.6 $ $Date: 2001/10/11 08:56:14 $
  + * @version CVS $Revision: 1.2.2.7 $ $Date: 2001/11/01 09:44:33 $
    */
   public abstract class AbstractTextSerializer extends AbstractSerializer implements Configurable,
Cacheable, Poolable {
   
  @@ -68,6 +74,16 @@
       private boolean hasMappings = false;
   
       /**
  +     * The default output buffer size.
  +     */
  +    private static final int DEFAULT_BUFFER_SIZE = 8192;
  +    
  +    /**
  +     * The output buffer size to use.
  +     */
  +    private int outputBufferSize = DEFAULT_BUFFER_SIZE;
  +    
  +    /**
        * Helper for TransformerFactory.
        */
       protected SAXTransformerFactory getTransformerFactory()
  @@ -80,11 +96,31 @@
       }
   
       /**
  +     * Set the <code>OutputStream</code> where the XML should be serialized.
  +     */
  +    public void setOutputStream(OutputStream out) {
  +        /*
  +         * Add a level of buffering to the output stream. Xalan serializes
  +         * every character individually. In conjunction with chunked
  +         * transfer encoding this would otherwise lead to a whopping 6-fold
  +         * increase of data on the wire.
  +         */
  +        BufferedOutputStream streamBuffer = new BufferedOutputStream(out, outputBufferSize);
  +        super.setOutputStream(streamBuffer);
  +    }
  +
  +    /**
        * Set the configurations for this serializer.
        */
       public void configure(Configuration conf)
         throws ConfigurationException {
   
  +        // configure buffer size
  +        Configuration bsc = conf.getChild("buffer-size", false);
  +        if(null != bsc)
  +          outputBufferSize = bsc.getValueAsInteger(DEFAULT_BUFFER_SIZE);
  +        
  +        // configure xalan
           Configuration cdataSectionElements = conf.getChild("cdata-section-elements");
           Configuration dtPublic = conf.getChild("doctype-public");
           Configuration dtSystem = conf.getChild("doctype-system");
  
  
  
  1.1.1.1.2.4 +2 -2      xml-cocoon2/src/org/apache/cocoon/serialization/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/serialization/HTMLSerializer.java,v
  retrieving revision 1.1.1.1.2.3
  retrieving revision 1.1.1.1.2.4
  diff -u -r1.1.1.1.2.3 -r1.1.1.1.2.4
  --- HTMLSerializer.java	2001/10/11 08:56:14	1.1.1.1.2.3
  +++ HTMLSerializer.java	2001/11/01 09:44:33	1.1.1.1.2.4
  @@ -17,7 +17,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.1.1.2.3 $ $Date: 2001/10/11 08:56:14 $
  + * @version CVS $Revision: 1.1.1.1.2.4 $ $Date: 2001/11/01 09:44:33 $
    */
   
   public class HTMLSerializer extends AbstractTextSerializer implements Poolable {
  @@ -32,7 +32,7 @@
               super.setOutputStream(out);
               handler = getTransformerFactory().newTransformerHandler();
               format.put(OutputKeys.METHOD,"html");
  -            handler.setResult(new StreamResult(out));
  +            handler.setResult(new StreamResult(this.output));
               handler.getTransformer().setOutputProperties(format);
               this.setContentHandler(handler);
               this.setLexicalHandler(handler);
  
  
  
  1.1.1.1.2.4 +2 -2      xml-cocoon2/src/org/apache/cocoon/serialization/TextSerializer.java
  
  Index: TextSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/serialization/TextSerializer.java,v
  retrieving revision 1.1.1.1.2.3
  retrieving revision 1.1.1.1.2.4
  diff -u -r1.1.1.1.2.3 -r1.1.1.1.2.4
  --- TextSerializer.java	2001/10/11 08:56:14	1.1.1.1.2.3
  +++ TextSerializer.java	2001/11/01 09:44:33	1.1.1.1.2.4
  @@ -17,7 +17,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.1.1.2.3 $ $Date: 2001/10/11 08:56:14 $
  + * @version CVS $Revision: 1.1.1.1.2.4 $ $Date: 2001/11/01 09:44:33 $
    */
   
   public class TextSerializer extends AbstractTextSerializer implements Poolable {
  @@ -32,7 +32,7 @@
               super.setOutputStream(out);
               handler = getTransformerFactory().newTransformerHandler();
               format.put(OutputKeys.METHOD,"text");
  -            handler.setResult(new StreamResult(out));
  +            handler.setResult(new StreamResult(this.output));
               handler.getTransformer().setOutputProperties(format);
               this.setContentHandler(handler);
               this.setLexicalHandler(handler);
  
  
  
  1.1.1.1.2.4 +2 -2      xml-cocoon2/src/org/apache/cocoon/serialization/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/serialization/XMLSerializer.java,v
  retrieving revision 1.1.1.1.2.3
  retrieving revision 1.1.1.1.2.4
  diff -u -r1.1.1.1.2.3 -r1.1.1.1.2.4
  --- XMLSerializer.java	2001/10/11 08:56:14	1.1.1.1.2.3
  +++ XMLSerializer.java	2001/11/01 09:44:33	1.1.1.1.2.4
  @@ -17,7 +17,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.1.1.2.3 $ $Date: 2001/10/11 08:56:14 $
  + * @version CVS $Revision: 1.1.1.1.2.4 $ $Date: 2001/11/01 09:44:33 $
    */
   
   public class XMLSerializer extends AbstractTextSerializer implements Poolable {
  @@ -32,7 +32,7 @@
               super.setOutputStream(out);
               this.handler = getTransformerFactory().newTransformerHandler();
               format.put(OutputKeys.METHOD,"xml");
  -            handler.setResult(new StreamResult(out));
  +            handler.setResult(new StreamResult(this.output));
               handler.getTransformer().setOutputProperties(format);
               this.setContentHandler(handler);
               this.setLexicalHandler(handler);
  
  
  

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