Expose getOutputStream() method on MTOMXMLStreamWriter
------------------------------------------------------
Key: WSCOMMONS-216
URL: https://issues.apache.org/jira/browse/WSCOMMONS-216
Project: WS-Commons
Issue Type: Improvement
Components: AXIOM
Reporter: Rich Scheuerle
Assignee: Rich Scheuerle
Expose a getOutputStream() method on the MTOMXMLStreamWriter. This can boost
performance for OMSourcedElement/OMDataSource items.
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.
I don't believe that adding getOutputStream() compromises the model.
Comments ?
Rich
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]