axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From R J Scheuerle Jr <>
Subject (AXIS2) Request Change to MTOMXMLStreamWriter
Date Fri, 13 Jul 2007 18:59:41 GMT

I wish to add a getOutputStream() method on the Axiom MTOMXMLStreamWriter.

This is a small change, but could help boost performance of users of

Here is the requested change to MTOMXMLStreamWriter

+ /**
+ * If the MTOMXMLStreamWriter is connected to an OutputStream
+ * then the OutputStream is returned. This allows a node
+ * (perhaps an OMSourcedElement) to write its content
+ * directly to the OutputStream.
+ * @return OutputStream or null
+ */
+ public OutputStream getOutputStream() throws XMLStreamException {
+   OutputStream os = outStream;
+   if (os != null) {
+     // Flush the state of the writer..Many times the
+     // write defers the writing of tag characters (>)
+     // until the next write. Flush out this character
+     this.writeCharacters("");
+     this.flush();
+   }
+   return os;
+ }

Here is the scenario that would have a performance boost.

(a) Transport layer invokes serializeAndConsume(OutputStream ...) on the OM
(b) The implementation of serializeAndConsume always wraps the OutputStream
with an MTOMXMLStreamWriter.
(c) The *serializeAndConsume(XMLStreamWriter ) is called on the children.
(d) One of the children is an OMSourcedElement, which is attached to a
OMDataSource which
wraps a data object (i.e. JAXB object).
(e) The OMDataSource.serialize(XMLStreamWriter) is invoked.

(f) Here's the problem. The implementation of OMDataSource (i.e. JAXB
OMDataSource object)
may have a faster mechanism for writing to an OutputStream than an
If the MTOMXMLStreamWriter exposed a getOutputStream() method, the
OMDataSource could write directly to it.
If the OMDataSource wraps an byte[], InputStream, Source, etc. there is an
even bigger performance savings..

The JIRA is

Comments ?
Rich Scheuerle
IBM Web Services
Apache Axis2 (
512-838-5115  (IBM TL 678-5115)
View raw message