You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by mo...@apache.org on 2001/11/01 10:16:07 UTC
cvs commit: xml-cocoon2/src/org/apache/cocoon/serialization AbstractSerializer.java AbstractTextSerializer.java HTMLSerializer.java TextSerializer.java XMLSerializer.java
morrijr 01/11/01 01:16:07
Modified: src/org/apache/cocoon/serialization 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
1.7 +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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractSerializer.java 2001/10/11 07:28:23 1.6
+++ AbstractSerializer.java 2001/11/01 09:16:07 1.7
@@ -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.6 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.7 $ $Date: 2001/11/01 09:16:07 $
*/
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.9 +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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AbstractTextSerializer.java 2001/10/11 07:28:23 1.8
+++ AbstractTextSerializer.java 2001/11/01 09:16:07 1.9
@@ -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.8 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.9 $ $Date: 2001/11/01 09:16:07 $
*/
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.5 +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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HTMLSerializer.java 2001/10/11 07:28:23 1.4
+++ HTMLSerializer.java 2001/11/01 09:16:07 1.5
@@ -17,7 +17,7 @@
/**
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.4 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.5 $ $Date: 2001/11/01 09:16:07 $
*/
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.5 +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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TextSerializer.java 2001/10/11 07:28:23 1.4
+++ TextSerializer.java 2001/11/01 09:16:07 1.5
@@ -17,7 +17,7 @@
/**
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.4 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.5 $ $Date: 2001/11/01 09:16:07 $
*/
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.5 +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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XMLSerializer.java 2001/10/11 07:28:23 1.4
+++ XMLSerializer.java 2001/11/01 09:16:07 1.5
@@ -17,7 +17,7 @@
/**
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.4 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.5 $ $Date: 2001/11/01 09:16:07 $
*/
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