001: /*
002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/RequestWrapper.java,v 1.4 2002/03/18 07:15:39 remm Exp $
003: * $Revision: 1.4 $
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.InputStream;
067: import java.io.IOException;
068: import java.net.Socket;
069: import javax.servlet.ServletException;
070: import javax.servlet.ServletInputStream;
071: import javax.servlet.ServletRequest;
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>Request</b>
080: * object. By default, all methods are delegated to the wrapped request,
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.4 $ $Date: 2002/03/18 07:15:39 $
086: * @deprecated
087: */
088:
089: public abstract class RequestWrapper implements Request {
090:
091: // ----------------------------------------------------------- Constructors
092:
093: /**
094: * Construct a wrapper for the specified request.
095: *
096: * @param request The request to be wrapped
097: */
098: public RequestWrapper(Request request) {
099:
100: super ();
101: this .request = request;
102:
103: }
104:
105: // ----------------------------------------------------- Instance Variables
106:
107: /**
108: * The wrapped request.
109: */
110: protected Request request = null;
111:
112: /**
113: * Return the wrapped request.
114: */
115: public Request getWrappedRequest() {
116:
117: return (this .request);
118:
119: }
120:
121: // ------------------------------------------------------------- Properties
122:
123: /**
124: * Return the authorization credentials sent with this request.
125: */
126: public String getAuthorization() {
127:
128: return (request.getAuthorization());
129:
130: }
131:
132: /**
133: * Set the authorization credentials sent with this request.
134: *
135: * @param authorization The new authorization credentials
136: */
137: public void setAuthorization(String authorization) {
138:
139: request.setAuthorization(authorization);
140:
141: }
142:
143: /**
144: * Return the Connector through which this Request was received.
145: */
146: public Connector getConnector() {
147:
148: return (request.getConnector());
149:
150: }
151:
152: /**
153: * Set the Connector through which this Request was received.
154: *
155: * @param connector The new connector
156: */
157: public void setConnector(Connector connector) {
158:
159: request.setConnector(connector);
160:
161: }
162:
163: /**
164: * Return the Context within which this Request is being processed.
165: */
166: public Context getContext() {
167:
168: return (request.getContext());
169:
170: }
171:
172: /**
173: * Set the Context within which this Request is being processed. This
174: * must be called as soon as the appropriate Context is identified, because
175: * it identifies the value to be returned by <code>getContextPath()</code>,
176: * and thus enables parsing of the request URI.
177: *
178: * @param context The newly associated Context
179: */
180: public void setContext(Context context) {
181:
182: request.setContext(context);
183:
184: }
185:
186: /**
187: * Return descriptive information about this Request implementation and
188: * the corresponding version number, in the format
189: * <code><description>/<version></code>.
190: */
191: public String getInfo() {
192:
193: return (request.getInfo());
194:
195: }
196:
197: /**
198: * Return the <code>ServletRequest</code> for which this object
199: * is the facade.
200: */
201: public ServletRequest getRequest() {
202:
203: return (request.getRequest());
204:
205: }
206:
207: /**
208: * Return the Response with which this Request is associated.
209: */
210: public Response getResponse() {
211:
212: return (request.getResponse());
213:
214: }
215:
216: /**
217: * Set the Response with which this Request is associated.
218: *
219: * @param response The new associated response
220: */
221: public void setResponse(Response response) {
222:
223: request.setResponse(response);
224:
225: }
226:
227: /**
228: * Return the Socket (if any) through which this Request was received.
229: * This should <strong>only</strong> be used to access underlying state
230: * information about this Socket, such as the SSLSession associated with
231: * an SSLSocket.
232: */
233: public Socket getSocket() {
234:
235: return (request.getSocket());
236:
237: }
238:
239: /**
240: * Set the Socket (if any) through which this Request was received.
241: *
242: * @param socket The socket through which this request was received
243: */
244: public void setSocket(Socket socket) {
245:
246: request.setSocket(socket);
247:
248: }
249:
250: /**
251: * Return the input stream associated with this Request.
252: */
253: public InputStream getStream() {
254:
255: return (request.getStream());
256:
257: }
258:
259: /**
260: * Set the input stream associated with this Request.
261: *
262: * @param stream The new input stream
263: */
264: public void setStream(InputStream stream) {
265:
266: request.setStream(stream);
267:
268: }
269:
270: /**
271: * Return the Wrapper within which this Request is being processed.
272: */
273: public Wrapper getWrapper() {
274:
275: return (request.getWrapper());
276:
277: }
278:
279: /**
280: * Set the Wrapper within which this Request is being processed. This
281: * must be called as soon as the appropriate Wrapper is identified, and
282: * before the Request is ultimately passed to an application servlet.
283: *
284: * @param wrapper The newly associated Wrapper
285: */
286: public void setWrapper(Wrapper wrapper) {
287:
288: request.setWrapper(wrapper);
289:
290: }
291:
292: // --------------------------------------------------------- Public Methods
293:
294: /**
295: * Create and return a ServletInputStream to read the content
296: * associated with this Request.
297: *
298: * @exception IOException if an input/output error occurs
299: */
300: public ServletInputStream createInputStream() throws IOException {
301:
302: return (request.createInputStream());
303:
304: }
305:
306: /**
307: * Perform whatever actions are required to flush and close the input
308: * stream or reader, in a single operation.
309: *
310: * @exception IOException if an input/output error occurs
311: */
312: public void finishRequest() throws IOException {
313:
314: request.finishRequest();
315:
316: }
317:
318: /**
319: * Release all object references, and initialize instance variables, in
320: * preparation for reuse of this object.
321: */
322: public void recycle() {
323:
324: request.recycle();
325:
326: }
327:
328: /**
329: * Set the content length associated with this Request.
330: *
331: * @param length The new content length
332: */
333: public void setContentLength(int length) {
334:
335: request.setContentLength(length);
336:
337: }
338:
339: /**
340: * Set the content type (and optionally the character encoding)
341: * associated with this Request. For example,
342: * <code>text/html; charset=ISO-8859-4</code>.
343: *
344: * @param type The new content type
345: */
346: public void setContentType(String type) {
347:
348: request.setContentType(type);
349:
350: }
351:
352: /**
353: * Set the protocol name and version associated with this Request.
354: *
355: * @param protocol Protocol name and version
356: */
357: public void setProtocol(String protocol) {
358:
359: request.setProtocol(protocol);
360:
361: }
362:
363: /**
364: * Set the remote IP address associated with this Request. NOTE: This
365: * value will be used to resolve the value for <code>getRemoteHost()</code>
366: * if that method is called.
367: *
368: * @param remote The remote IP address
369: */
370: public void setRemoteAddr(String remote) {
371:
372: request.setRemoteAddr(remote);
373:
374: }
375:
376: /**
377: * Set the name of the scheme associated with this request. Typical values
378: * are <code>http</code>, <code>https</code>, and <code>ftp</code>.
379: *
380: * @param scheme The scheme
381: */
382: public void setScheme(String scheme) {
383:
384: request.setScheme(scheme);
385:
386: }
387:
388: /**
389: * Set the value to be returned by <code>isSecure()</code>
390: * for this Request.
391: *
392: * @param secure The new isSecure value
393: */
394: public void setSecure(boolean secure) {
395:
396: request.setSecure(secure);
397:
398: }
399:
400: /**
401: * Set the name of the server (virtual host) to process this request.
402: *
403: * @param name The server name
404: */
405: public void setServerName(String name) {
406:
407: request.setServerName(name);
408:
409: }
410:
411: /**
412: * Set the port number of the server to process this request.
413: *
414: * @param port The server port
415: */
416: public void setServerPort(int port) {
417:
418: request.setServerPort(port);
419:
420: }
421:
422: }
|