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 sc...@apache.org on 2007/07/13 23:55:10 UTC

svn commit: r556158 - /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java

Author: scheu
Date: Fri Jul 13 14:55:09 2007
New Revision: 556158

URL: http://svn.apache.org/viewvc?view=rev&rev=556158
Log:
JIRA WSCOMMONS-216
Contributor: Rich Scheuerle
Expose a getOutputStream method on MTOMXMLStreamWriter.
This will allow OMDataSource implementations to write 
directly to an OutputStream (if available) and bypass the
heavyweight XMLStreamWriter interface.

I will also commit a follow-on patch (from Axis2/JAXWS) that
demonstrates how this can be exploited (by JAXB marshalling).
Perhaps future work can exploit this capability for ADB objects, byte[] etc.

While coding this, I noticed some peculiar code related to 
buffering the SOAP xml when attachments are optimized.  
I added a TODO for possible future work.  

Thanks,
Rich

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java?view=diff&rev=556158&r1=556157&r2=556158
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MTOMXMLStreamWriter.java Fri Jul 13 14:55:09 2007
@@ -297,4 +297,33 @@
     public void setOutputFormat(OMOutputFormat format) {
         this.format = format;
     }
+    
+    /**
+     * If this XMLStreamWriter 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 {
+        
+        // TODO: The presence of a bufferedSOAPBody means that we are not writing directly to the 
+        // OutputStream.  Need some redesign work here because (a) bufferedSOAPBody is not a soap body it 
+        // is the SOAP envelope xml. And (b) probably should make bufferedSOAPBody an OutputStream instead
+        // of a StringWriter (and avoid conversions to and from a String).  And (c) we can change this
+        // code to return the buffered OutputStream.
+        if (bufferedSOAPBody == null) {
+            return null;
+        }
+        
+        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;
+    }
 }



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