(AXIS2) Request Change to MTOMXMLStreamWriter

R J Scheuerle Jr <[email protected]>
Newsgroups gmane.text.xml.axis.devel,gmane.text.xml.commons.devel
Message-ID <OFD891E6B6.B7002562-ON87257317.006746B8-86257317.006815A1@us.ibm.com>
I wish to add a getOutputStream() method on the Axiom MTOMXMLStreamWriter.

This is a small change, but could help boost performance of users of
OMSourcedElement/OMDataSource.

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
tree.
(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
XMLStreamWriter.
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 https://issues.apache.org/jira/browse/WSCOMMONS-216

Comments ?
Rich Scheuerle
IBM Web Services
Apache Axis2 ([email protected])
512-838-5115  (IBM TL 678-5115)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.