Author: dims
Date: Sun Nov 26 19:18:00 2006
New Revision: 479504

URL: http://svn.apache.org/viewvc?view=rev&rev=479504
Log:
add an option to close the mtomwriter (clean up memory of the created 
XMLStreamWriter)

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

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java?view=diff&rev=479504&r1=479503&r2=479504
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
 Sun Nov 26 19:18:00 2006
@@ -46,6 +46,7 @@
     private String charSetEncoding;
     private String xmlVersion;
     private boolean ignoreXMLDeclaration = false;
+    private boolean autoCloseWriter = false;
 
 
     public OMOutputFormat() {
@@ -179,4 +180,12 @@
            sb.append("start=\"<" + getRootContentId() + ">\"");
            return sb.toString();
        }
+
+    public boolean isAutoCloseWriter() {
+        return autoCloseWriter;
+    }
+
+    public void setAutoCloseWriter(boolean autoCloseWriter) {
+        this.autoCloseWriter = autoCloseWriter;
+    }
 }

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=479504&r1=479503&r2=479504
==============================================================================
--- 
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
 Sun Nov 26 19:18:00 2006
@@ -397,6 +397,9 @@
         MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
         internalSerialize(writer);
         writer.flush();
+        if(format.isAutoCloseWriter()){
+            writer.close();
+        }
     }
 
     public void serialize(Writer writer2, OMOutputFormat format) throws 
XMLStreamException {
@@ -404,12 +407,18 @@
         writer.setOutputFormat(format);
         internalSerialize(writer);
         writer.flush();
+        if(format.isAutoCloseWriter()){
+            writer.close();
+        }
     }
 
     public void serializeAndConsume(OutputStream output, OMOutputFormat 
format) throws XMLStreamException {
         MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format);
         internalSerializeAndConsume(writer);
         writer.flush();
+        if(format.isAutoCloseWriter()){
+            writer.close();
+        }
     }
 
     public void serializeAndConsume(Writer writer2, OMOutputFormat format) 
throws XMLStreamException {
@@ -417,6 +426,9 @@
         writer.setOutputFormat(format);
         internalSerializeAndConsume(writer);
         writer.flush();
+        if(format.isAutoCloseWriter()){
+            writer.close();
+        }
     }
 
     public OMFactory getOMFactory() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to