01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry;
16:
17: import org.apache.tapestry.services.Response;
18:
19: import java.io.BufferedInputStream;
20: import java.io.IOException;
21: import java.io.InputStream;
22:
23: /**
24: * An alternate response from a component event handler method used to directly provide a stream of
25: * data to be sent to the client, rather than indicating what page to send a render redirect request
26: * to.
27: */
28: public interface StreamResponse {
29: /** Returns the content type to be reported to the client. */
30: String getContentType();
31:
32: /**
33: * Returns the stream of bytes to be sent to the client. The stream will be closed when the end
34: * of the stream is reached. The provided stream will be wrapped in a
35: * {@link BufferedInputStream} for efficiency.
36: */
37: InputStream getStream() throws IOException;
38:
39: /**
40: * Prepare response before it is sent to the client.
41: * This is the place to set any response headers (e.g. content-disposition)
42: * @param response Response that will be sent.
43: */
44: void prepareResponse(Response response);
45:
46: }
|