Re: (AXIS2) Request Change to MTOMXMLStreamWriter
"Davanum Srinivas" <[email protected]>
| Newsgroups | gmane.text.xml.axis.devel,gmane.text.xml.commons.devel |
|---|---|
| Message-ID | <[email protected]> |
Sounds good to me! On 7/13/07, R J Scheuerle Jr <[email protected]> wrote: > > 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) -- Davanum Srinivas :: http://davanum.wordpress.com