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/08/10 22:19:02 UTC

svn commit: r564748 - in /webservices/commons/trunk/modules/axiom/modules: axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/

Author: scheu
Date: Fri Aug 10 13:19:01 2007
New Revision: 564748

URL: http://svn.apache.org/viewvc?view=rev&rev=564748
Log:
WSCOMMONS-222
Okay here is the real change. 

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?view=diff&rev=564748&r1=564747&r2=564748
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java Fri Aug 10 13:19:01 2007
@@ -729,29 +729,53 @@
     }
 
     public void serialize(OutputStream output) throws XMLStreamException {
-        serialize(StAXUtils.createXMLStreamWriter(output));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
+        try {
+            serialize(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serialize(Writer writer) throws XMLStreamException {
-        serialize(StAXUtils.createXMLStreamWriter(writer));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+        try {
+            serialize(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serializeAndConsume(OutputStream output)
             throws XMLStreamException {
-        serializeAndConsume(StAXUtils
-                .createXMLStreamWriter(output));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
+        try {
+            serializeAndConsume(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serializeAndConsume(Writer writer) throws XMLStreamException {
-        serializeAndConsume(StAXUtils
-                .createXMLStreamWriter(writer));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+        try {
+            serializeAndConsume(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serialize(OutputStream output, OMOutputFormat format)
             throws XMLStreamException {
         MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
-        internalSerialize(writer);
-        writer.flush();
+        try {
+            internalSerialize(writer);
+            writer.flush();
+        } finally {
+            if (format.isAutoCloseWriter()) {
+                writer.close();
+            }
+        }
     }
 
     public void serialize(Writer writer2, OMOutputFormat format)
@@ -759,24 +783,42 @@
         MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(StAXUtils
                 .createXMLStreamWriter(writer2));
         writer.setOutputFormat(format);
-        internalSerialize(writer);
-        writer.flush();
+        try {
+            internalSerialize(writer);
+            writer.flush();
+        } finally {
+            if (format.isAutoCloseWriter()) {
+                writer.close();
+            }
+        }
     }
 
     public void serializeAndConsume(OutputStream output, OMOutputFormat format)
             throws XMLStreamException {
         MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
-        internalSerializeAndConsume(writer);
-        writer.flush();
+        try {
+            internalSerializeAndConsume(writer);
+            writer.flush();
+        } finally {
+            if (format.isAutoCloseWriter()) {
+                writer.close();
+            }
+        }
     }
 
     public void serializeAndConsume(Writer writer2, OMOutputFormat format)
             throws XMLStreamException {
         MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(StAXUtils
                 .createXMLStreamWriter(writer2));
-        writer.setOutputFormat(format);
-        internalSerializeAndConsume(writer);
-        writer.flush();
+        try {
+            writer.setOutputFormat(format);
+            internalSerializeAndConsume(writer);
+            writer.flush();
+        } finally {
+            if (format.isAutoCloseWriter()) {
+                writer.close();
+            }
+        }
     }
 
     /** Returns the <code>OMFactory</code> that created this node */

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?view=diff&rev=564748&r1=564747&r2=564748
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Fri Aug 10 13:19:01 2007
@@ -901,8 +901,12 @@
     public String toStringWithConsume() throws XMLStreamException {
         StringWriter writer = new StringWriter();
         XMLStreamWriter writer2 = StAXUtils.createXMLStreamWriter(writer);
-        this.serializeAndConsume(writer2);
-        writer2.flush();
+        try {
+            this.serializeAndConsume(writer2);
+            writer2.flush();
+        } finally {
+            writer2.close();
+        }
         return writer.toString();
     }
 
@@ -910,8 +914,12 @@
         StringWriter writer = new StringWriter();
         try {
             XMLStreamWriter writer2 = StAXUtils.createXMLStreamWriter(writer);
-            this.serialize(writer2);
-            writer2.flush();
+            try {
+                this.serialize(writer2);
+                writer2.flush();
+            } finally {
+                writer2.close();
+            }
         } catch (XMLStreamException e) {
             throw new RuntimeException("Can not serialize OM Element " + this.getLocalName(), e);
         }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java?view=diff&rev=564748&r1=564747&r2=564748
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java Fri Aug 10 13:19:01 2007
@@ -380,19 +380,39 @@
     }
 
     public void serialize(OutputStream output) throws XMLStreamException {
-        serialize(StAXUtils.createXMLStreamWriter(output));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
+        try {
+            serialize(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serialize(Writer writer) throws XMLStreamException {
-        serialize(StAXUtils.createXMLStreamWriter(writer));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+        try {
+            serialize(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serializeAndConsume(OutputStream output) throws XMLStreamException {
-        serializeAndConsume(StAXUtils.createXMLStreamWriter(output));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(output);
+        try {
+            serializeAndConsume(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serializeAndConsume(Writer writer) throws XMLStreamException {
-        serializeAndConsume(StAXUtils.createXMLStreamWriter(writer));
+        XMLStreamWriter xmlStreamWriter = StAXUtils.createXMLStreamWriter(writer);
+        try {
+            serializeAndConsume(xmlStreamWriter);
+        } finally {
+            xmlStreamWriter.close();
+        }
     }
 
     public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?view=diff&rev=564748&r1=564747&r2=564748
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Fri Aug 10 13:19:01 2007
@@ -689,10 +689,12 @@
         if (isDebugEnabled) {
             log.debug("serialize " + getPrintableName() + " to output stream");
         }
+        OMOutputFormat format = new OMOutputFormat();
+        format.setAutoCloseWriter(true);
         if (isExpanded()) {
-            super.serializeAndConsume(output, new OMOutputFormat());
+            super.serializeAndConsume(output, format);
         } else {
-            dataSource.serialize(output, new OMOutputFormat());
+            dataSource.serialize(output, format);
         }
     }
 
@@ -706,7 +708,9 @@
         if (isExpanded()) {
             super.serializeAndConsume(writer);
         } else {
-            dataSource.serialize(writer, new OMOutputFormat()); 
+            OMOutputFormat format = new OMOutputFormat();
+            format.setAutoCloseWriter(true);
+            dataSource.serialize(writer, format); 
         }
     }
 



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