You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by R J Scheuerle Jr <sc...@us.ibm.com> on 2007/07/13 20:59:41 UTC

(AXIS2) Request Change to MTOMXMLStreamWriter

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 (scheu@apache.org)
512-838-5115  (IBM TL 678-5115)

Re: (AXIS2) Request Change to MTOMXMLStreamWriter

Posted by Davanum Srinivas <da...@gmail.com>.
Sounds good to me!

On 7/13/07, R J Scheuerle Jr <sc...@us.ibm.com> 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 (scheu@apache.org)
> 512-838-5115  (IBM TL 678-5115)


-- 
Davanum Srinivas :: http://davanum.wordpress.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


Re: (AXIS2) Request Change to MTOMXMLStreamWriter

Posted by Davanum Srinivas <da...@gmail.com>.
Sounds good to me!

On 7/13/07, R J Scheuerle Jr <sc...@us.ibm.com> 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 (scheu@apache.org)
> 512-838-5115  (IBM TL 678-5115)


-- 
Davanum Srinivas :: http://davanum.wordpress.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org