Author: jcompagner
Date: Thu Sep 13 15:22:11 2007
New Revision: 575485
URL: http://svn.apache.org/viewvc?rev=575485&view=rev
Log:
WICKET-964 provide direct access on output stream in resources
Added:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/IResourceStreamWriter.java
(with props)
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/resource/ResourceStreamRequestTarget.java
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/resource/ResourceStreamRequestTarget.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/resource/ResourceStreamRequestTarget.java?rev=575485&r1=575484&r2=575485&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/resource/ResourceStreamRequestTarget.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/resource/ResourceStreamRequestTarget.java
Thu Sep 13 15:22:11 2007
@@ -24,6 +24,7 @@
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.protocol.http.request.WebErrorCodeResponseTarget;
import org.apache.wicket.util.resource.IResourceStream;
+import org.apache.wicket.util.resource.IResourceStreamWriter;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,8 +41,8 @@
private static final Logger log =
LoggerFactory.getLogger(ResourceStreamRequestTarget.class);
/**
- * Optional filename, used to set the content disposition header. Only
- * meaningful when using with web requests.
+ * Optional filename, used to set the content disposition header. Only
meaningful when using
+ * with web requests.
*/
private String fileName;
@@ -81,8 +82,8 @@
}
/**
- * @return Optional filename, used to set the content disposition
header.
- * Only meaningful when using with web requests.
+ * @return Optional filename, used to set the content disposition
header. Only meaningful when
+ * using with web requests.
*/
public String getFileName()
{
@@ -124,7 +125,10 @@
try
{
- response.write(resourceStream.getInputStream());
+ if (resourceStream instanceof IResourceStreamWriter)
+
((IResourceStreamWriter)resourceStream).write(response.getOutputStream());
+ else
+ response.write(resourceStream.getInputStream());
}
catch (ResourceStreamNotFoundException e)
{
@@ -135,8 +139,8 @@
/**
* @param fileName
- * Optional filename, used to set the content disposition
header.
- * Only meaningful when using with web requests.
+ * Optional filename, used to set the content disposition
header. Only meaningful
+ * when using with web requests.
*
* @return The this.
*/
@@ -156,8 +160,8 @@
}
/**
- * Configures the response, default by setting the content type and
length
- * and content disposition (in case the fileName property was set).
+ * Configures the response, default by setting the content type and
length and content
+ * disposition (in case the fileName property was set).
*
* @param requestCycle
* @param response
Added:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/IResourceStreamWriter.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/IResourceStreamWriter.java?rev=575485&view=auto
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/IResourceStreamWriter.java
(added)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/IResourceStreamWriter.java
Thu Sep 13 15:22:11 2007
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.resource;
+
+import java.io.OutputStream;
+
+/**
+ * Special IResourceStream implementation that a Resource can return when it
directly wants to write
+ * to an output stream instead of return the [EMAIL PROTECTED]
IResourceStream#getInputStream()}. That one can
+ * return null for a IResourceStreamWriter.
+ *
+ * This behavior comes in use when the resource is generated on the fly and
should be streamed
+ * directly to the client so that it won't be buffered completely if the
generated resource is
+ * really big.
+ *
+ * @author jcompagner
+ */
+public interface IResourceStreamWriter extends IResourceStream
+{
+ /**
+ * Implement this method to write the resource data directly the the
given OutputStream.
+ *
+ * @param output
+ * The output stream where the resource can write its
content into.
+ */
+ void write(OutputStream output);
+}
Propchange:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/IResourceStreamWriter.java
------------------------------------------------------------------------------
svn:eol-style = native