cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r606101 - /incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
Date Fri, 21 Dec 2007 05:32:01 GMT
Author: mmao
Date: Thu Dec 20 21:32:00 2007
New Revision: 606101

URL: http://svn.apache.org/viewvc?rev=606101&view=rev
Log:
* Using CachedOutputStream instead of byte[]


Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java?rev=606101&r1=606100&r2=606101&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
Thu Dec 20 21:32:00 2007
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.attachment;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -27,15 +26,17 @@
 import javax.activation.DataSource;
 
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
 
 public class AttachmentDataSource implements DataSource {
 
-    private final String ct;
-    private final byte[] cache; 
+    private final String ct;    
+    private final CachedOutputStream cache;
     
     public AttachmentDataSource(String ctParam, InputStream inParam) throws IOException {
-        this.ct = ctParam;
-        cache = IOUtils.readBytesFromStream(inParam);
+        this.ct = ctParam;        
+        cache = new CachedOutputStream();
+        IOUtils.copy(inParam, cache);
     }
 
     public String getContentType() {
@@ -43,7 +44,12 @@
     }
 
     public InputStream getInputStream() {
-        return new DelegatingInputStream(new ByteArrayInputStream(cache));
+        try {
+            return new DelegatingInputStream(cache.getInputStream());
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
     }
 
     public String getName() {
@@ -53,6 +59,4 @@
     public OutputStream getOutputStream() throws IOException {
         throw new UnsupportedOperationException();
     }
-
-
-}
+}
\ No newline at end of file



Mime
View raw message