001: /*
002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/ResponseWrapper.java,v 1.3 2002/03/18 07:15:39 remm Exp $
003: * $Revision: 1.3 $
004: * $Date: 2002/03/18 07:15:39 $
005: *
006: * ====================================================================
007: *
008: * The Apache Software License, Version 1.1
009: *
010: * Copyright (c) 1999 The Apache Software Foundation. All rights
011: * reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions
015: * are met:
016: *
017: * 1. Redistributions of source code must retain the above copyright
018: * notice, this list of conditions and the following disclaimer.
019: *
020: * 2. Redistributions in binary form must reproduce the above copyright
021: * notice, this list of conditions and the following disclaimer in
022: * the documentation and/or other materials provided with the
023: * distribution.
024: *
025: * 3. The end-user documentation included with the redistribution, if
026: * any, must include the following acknowlegement:
027: * "This product includes software developed by the
028: * Apache Software Foundation (http://www.apache.org/)."
029: * Alternately, this acknowlegement may appear in the software itself,
030: * if and wherever such third-party acknowlegements normally appear.
031: *
032: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033: * Foundation" must not be used to endorse or promote products derived
034: * from this software without prior written permission. For written
035: * permission, please contact apache@apache.org.
036: *
037: * 5. Products derived from this software may not be called "Apache"
038: * nor may "Apache" appear in their names without prior written
039: * permission of the Apache Group.
040: *
041: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052: * SUCH DAMAGE.
053: * ====================================================================
054: *
055: * This software consists of voluntary contributions made by many
056: * individuals on behalf of the Apache Software Foundation. For more
057: * information on the Apache Software Foundation, please see
058: * <http://www.apache.org/>.
059: *
060: * [Additional notices, if required by prior licensing conditions]
061: *
062: */
063:
064: package org.apache.catalina.connector;
065:
066: import java.io.IOException;
067: import java.io.OutputStream;
068: import java.io.PrintWriter;
069: import javax.servlet.ServletException;
070: import javax.servlet.ServletOutputStream;
071: import javax.servlet.ServletResponse;
072: import org.apache.catalina.Connector;
073: import org.apache.catalina.Context;
074: import org.apache.catalina.Request;
075: import org.apache.catalina.Response;
076: import org.apache.catalina.Wrapper;
077:
078: /**
079: * Abstract convenience class that wraps a Catalina-internal <b>Response</b>
080: * object. By default, all methods are delegated to the wrapped response,
081: * but subclasses can override individual methods as required to provide the
082: * functionality that they require.
083: *
084: * @author Craig R. McClanahan
085: * @version $Revision: 1.3 $ $Date: 2002/03/18 07:15:39 $
086: * @deprecated
087: */
088:
089: public abstract class ResponseWrapper implements Response {
090:
091: // ----------------------------------------------------------- Constructors
092:
093: /**
094: * Construct a wrapper for the specified response.
095: *
096: * @param response The response to be wrapped
097: */
098: public ResponseWrapper(Response response) {
099:
100: super ();
101: this .response = response;
102:
103: }
104:
105: // ----------------------------------------------------- Instance Variables
106:
107: /**
108: * The wrapped response.
109: */
110: protected Response response = null;
111:
112: /**
113: * Return the wrapped response.
114: */
115: public Response getWrappedResponse() {
116:
117: return (this .response);
118:
119: }
120:
121: // ------------------------------------------------------------- Properties
122:
123: /**
124: * Return the Connector through which this Response is returned.
125: */
126: public Connector getConnector() {
127:
128: return (response.getConnector());
129:
130: }
131:
132: /**
133: * Set the Connector through which this Response is returned.
134: *
135: * @param connector The new connector
136: */
137: public void setConnector(Connector connector) {
138:
139: response.setConnector(connector);
140:
141: }
142:
143: /**
144: * Return the number of bytes actually written to the output stream.
145: */
146: public int getContentCount() {
147:
148: return (response.getContentCount());
149:
150: }
151:
152: /**
153: * Return the Context with which this Response is associated.
154: */
155: public Context getContext() {
156:
157: return (response.getContext());
158:
159: }
160:
161: /**
162: * Set the Context with which this Response is associated. This should
163: * be called as soon as the appropriate Context is identified.
164: *
165: * @param context The associated Context
166: */
167: public void setContext(Context context) {
168:
169: response.setContext(context);
170:
171: }
172:
173: /**
174: * Return the "processing inside an include" flag.
175: */
176: public boolean getIncluded() {
177:
178: return (response.getIncluded());
179:
180: }
181:
182: /**
183: * Set the "processing inside an include" flag.
184: *
185: * @param included <code>true</code> if we are currently inside a
186: * RequestDispatcher.include(), else <code>false</code>
187: */
188: public void setIncluded(boolean included) {
189:
190: response.setIncluded(included);
191:
192: }
193:
194: /**
195: * Return descriptive information about this Response implementation and
196: * the corresponding version number, in the format
197: * <code><description>/<version></code>.
198: */
199: public String getInfo() {
200:
201: return (response.getInfo());
202:
203: }
204:
205: /**
206: * Return the Request with which this Response is associated.
207: */
208: public Request getRequest() {
209:
210: return (response.getRequest());
211:
212: }
213:
214: /**
215: * Set the Request with which this Response is associated.
216: *
217: * @param request The new associated request
218: */
219: public void setRequest(Request request) {
220:
221: response.setRequest(request);
222:
223: }
224:
225: /**
226: * Return the <code>ServletResponse</code> for which this object
227: * is the facade.
228: */
229: public ServletResponse getResponse() {
230:
231: return (response.getResponse());
232:
233: }
234:
235: /**
236: * Return the output stream associated with this Response.
237: */
238: public OutputStream getStream() {
239:
240: return (response.getStream());
241:
242: }
243:
244: /**
245: * Set the output stream associated with this Response.
246: *
247: * @param stream The new output stream
248: */
249: public void setStream(OutputStream stream) {
250:
251: response.setStream(stream);
252:
253: }
254:
255: // --------------------------------------------------------- Public Methods
256:
257: /**
258: * Create and return a ServletOutputStream to write the content
259: * associated with this Response.
260: *
261: * @exception IOException if an input/output error occurs
262: */
263: public ServletOutputStream createOutputStream() throws IOException {
264:
265: return (response.createOutputStream());
266:
267: }
268:
269: /**
270: * Perform whatever actions are required to flush and close the output
271: * stream or writer, in a single operation.
272: *
273: * @exception IOException if an input/output error occurs
274: */
275: public void finishResponse() throws IOException {
276:
277: response.finishResponse();
278:
279: }
280:
281: /**
282: * Return the content length that was set or calculated for this Response.
283: */
284: public int getContentLength() {
285:
286: return (response.getContentLength());
287:
288: }
289:
290: /**
291: * Return the content type that was set or calculated for this response,
292: * or <code>null</code> if no content type was set.
293: */
294: public String getContentType() {
295:
296: return (response.getContentType());
297:
298: }
299:
300: /**
301: * Return a PrintWriter that can be used to render error messages,
302: * regardless of whether a stream or writer has already been acquired.
303: */
304: public PrintWriter getReporter() {
305:
306: return (response.getReporter());
307:
308: }
309:
310: /**
311: * Release all object references, and initialize instance variables, in
312: * preparation for reuse of this object.
313: */
314: public void recycle() {
315:
316: response.recycle();
317:
318: }
319:
320: /**
321: * Reset the data buffer but not any status or header information.
322: */
323: public void resetBuffer() {
324:
325: response.resetBuffer();
326:
327: }
328:
329: }
|