tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1087481 - in /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5: internal/services/assets/BytestreamCache.java internal/services/assets/StreamableResourceImpl.java services/assets/StreamableResource.java
Date Thu, 31 Mar 2011 23:15:12 GMT
Author: hlship
Date: Thu Mar 31 23:15:12 2011
New Revision: 1087481

URL: http://svn.apache.org/viewvc?rev=1087481&view=rev
Log:
TAP5-73: Add a method to StreamableResource to allow access to the underlying InputStream
for the resource's content

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/BytestreamCache.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/BytestreamCache.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/BytestreamCache.java?rev=1087481&r1=1087480&r2=1087481&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/BytestreamCache.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/BytestreamCache.java
Thu Mar 31 23:15:12 2011
@@ -14,8 +14,10 @@
 
 package org.apache.tapestry5.internal.services.assets;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 
 /**
@@ -48,4 +50,9 @@ public class BytestreamCache
     {
         return streamData.length;
     }
+
+    public InputStream openStream()
+    {
+        return new ByteArrayInputStream(streamData);
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java?rev=1087481&r1=1087480&r2=1087481&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/StreamableResourceImpl.java
Thu Mar 31 23:15:12 2011
@@ -15,6 +15,7 @@
 package org.apache.tapestry5.internal.services.assets;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.tapestry5.services.assets.CompressionStatus;
@@ -64,6 +65,11 @@ public class StreamableResourceImpl impl
         bytestreamCache.writeTo(os);
     }
 
+    public InputStream openStream() throws IOException
+    {
+        return bytestreamCache.openStream();
+    }
+
     @Override
     public String toString()
     {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java?rev=1087481&r1=1087480&r2=1087481&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/StreamableResource.java
Thu Mar 31 23:15:12 2011
@@ -15,6 +15,7 @@
 package org.apache.tapestry5.services.assets;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.tapestry5.ioc.Resource;
@@ -45,6 +46,15 @@ public interface StreamableResource
     void streamTo(OutputStream os) throws IOException;
 
     /**
+     * Opens the content of the resource as an input stream; the caller is responsible for
closing the stream
+     * after reading it.
+     * 
+     * @return stream of the contents of the resource
+     * @throws IOException
+     */
+    InputStream openStream() throws IOException;
+
+    /**
      * Returns the time the resource was last modified, with accuracy to one second (so as
to match
      * the HTTP request/response date headers.
      */



Mime
View raw message