Author: veithen
Date: Sat Dec  3 10:38:44 2011
New Revision: 1209882

URL: http://svn.apache.org/viewvc?rev=1209882&view=rev
Log:
AXIOM-377: Make sure that PartDataHandler overrides writeTo.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java?rev=1209882&r1=1209881&r2=1209882&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java
 Sat Dec  3 10:38:44 2011
@@ -20,13 +20,13 @@ package org.apache.axiom.attachments;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 
 import org.apache.axiom.attachments.lifecycle.DataHandlerExt;
 
-// TODO: we should override writeTo and delegate to PartImpl#writeTo
 class PartDataHandler extends DataHandler implements DataHandlerExt {
     private final PartImpl part;
     private DataSource dataSource;
@@ -55,6 +55,13 @@ class PartDataHandler extends DataHandle
         return dataSource;
     }
 
+    public void writeTo(OutputStream os) throws IOException {
+        // The PartContent may have an implementation of writeTo that is more 
efficient than the default
+        // DataHandler#writeTo method (which requests an input stream and then 
copies it to the output
+        // stream).
+        part.writeTo(os);
+    }
+
     public InputStream readOnce() throws IOException {
         return part.getInputStream(false);
     }


Reply via email to