1 /*
2 * Copyright 1999-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.apache.coyote.tomcat4;
18
19
20 import java.io.BufferedReader;
21 import java.io.IOException;
22 import java.util.Enumeration;
23 import java.util.Locale;
24 import java.util.Map;
25
26 import javax.servlet.RequestDispatcher;
27 import javax.servlet.ServletInputStream;
28 import javax.servlet.http.Cookie;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpSession;
31
32 import org.apache.catalina.connector.RequestFacade;
33
34
35 /**
36 * Facade class that wraps a Coyote request object.
37 * All methods are delegated to the wrapped request.
38 *
39 * @author Craig R. McClanahan
40 * @author Remy Maucherat
41 * @version $Revision: 299222 $ $Date: 2004-02-24 04:02:18 -0500 (Tue, 24 Feb 2004) $
42 */
43
44 public class CoyoteRequestFacade
45 extends RequestFacade
46 implements HttpServletRequest {
47
48
49 // ----------------------------------------------------------- Constructors
50
51
52 /**
53 * Construct a wrapper for the specified request.
54 *
55 * @param request The request to be wrapped
56 */
57 public CoyoteRequestFacade(CoyoteRequest request) {
58
59 super(request);
60 this.request = request;
61
62 }
63
64
65 // ----------------------------------------------------- Instance Variables
66
67
68 /**
69 * The wrapped request.
70 */
71 protected CoyoteRequest request = null;
72
73
74 // --------------------------------------------------------- Public Methods
75
76
77 /**
78 * Clear facade.
79 */
80 public void clear() {
81 request = null;
82 }
83
84
85 // ------------------------------------------------- ServletRequest Methods
86
87
88 public Object getAttribute(String name) {
89 return request.getAttribute(name);
90 }
91
92
93 public Enumeration getAttributeNames() {
94 return request.getAttributeNames();
95 }
96
97
98 public String getCharacterEncoding() {
99 return request.getCharacterEncoding();
100 }
101
102
103 public void setCharacterEncoding(String env)
104 throws java.io.UnsupportedEncodingException {
105 request.setCharacterEncoding(env);
106 }
107
108
109 public int getContentLength() {
110 return request.getContentLength();
111 }
112
113
114 public String getContentType() {
115 return request.getContentType();
116 }
117
118
119 public ServletInputStream getInputStream()
120 throws IOException {
121 return request.getInputStream();
122 }
123
124
125 public String getParameter(String name) {
126 return request.getParameter(name);
127 }
128
129
130 public Enumeration getParameterNames() {
131 return request.getParameterNames();
132 }
133
134
135 public String[] getParameterValues(String name) {
136 return request.getParameterValues(name);
137 }
138
139
140 public Map getParameterMap() {
141 return request.getParameterMap();
142 }
143
144
145 public String getProtocol() {
146 return request.getProtocol();
147 }
148
149
150 public String getScheme() {
151 return request.getScheme();
152 }
153
154
155 public String getServerName() {
156 return request.getServerName();
157 }
158
159
160 public int getServerPort() {
161 return request.getServerPort();
162 }
163
164
165 public BufferedReader getReader()
166 throws IOException {
167 return request.getReader();
168 }
169
170
171 public String getRemoteAddr() {
172 return request.getRemoteAddr();
173 }
174
175
176 public String getRemoteHost() {
177 return request.getRemoteHost();
178 }
179
180
181 public void setAttribute(String name, Object o) {
182 request.setAttribute(name, o);
183 }
184
185
186 public void removeAttribute(String name) {
187 request.removeAttribute(name);
188 }
189
190
191 public Locale getLocale() {
192 return request.getLocale();
193 }
194
195
196 public Enumeration getLocales() {
197 return request.getLocales();
198 }
199
200
201 public boolean isSecure() {
202 return request.isSecure();
203 }
204
205
206 public RequestDispatcher getRequestDispatcher(String path) {
207 // TODO : Facade !!
208 return request.getRequestDispatcher(path);
209 }
210
211
212 public String getRealPath(String path) {
213 return request.getRealPath(path);
214 }
215
216
217 public String getAuthType() {
218 return request.getAuthType();
219 }
220
221
222 public Cookie[] getCookies() {
223 return request.getCookies();
224 }
225
226
227 public long getDateHeader(String name) {
228 return request.getDateHeader(name);
229 }
230
231
232 public String getHeader(String name) {
233 return request.getHeader(name);
234 }
235
236
237 public Enumeration getHeaders(String name) {
238 return request.getHeaders(name);
239 }
240
241
242 public Enumeration getHeaderNames() {
243 return request.getHeaderNames();
244 }
245
246
247 public int getIntHeader(String name) {
248 return request.getIntHeader(name);
249 }
250
251
252 public String getMethod() {
253 return request.getMethod();
254 }
255
256
257 public String getPathInfo() {
258 return request.getPathInfo();
259 }
260
261
262 public String getPathTranslated() {
263 return request.getPathTranslated();
264 }
265
266
267 public String getContextPath() {
268 return request.getContextPath();
269 }
270
271
272 public String getQueryString() {
273 return request.getQueryString();
274 }
275
276
277 public String getRemoteUser() {
278 return request.getRemoteUser();
279 }
280
281
282 public boolean isUserInRole(String role) {
283 return request.isUserInRole(role);
284 }
285
286
287 public java.security.Principal getUserPrincipal() {
288 return request.getUserPrincipal();
289 }
290
291
292 public String getRequestedSessionId() {
293 return request.getRequestedSessionId();
294 }
295
296
297 public String getRequestURI() {
298 return request.getRequestURI();
299 }
300
301
302 public StringBuffer getRequestURL() {
303 return request.getRequestURL();
304 }
305
306
307 public String getServletPath() {
308 return request.getServletPath();
309 }
310
311
312 public HttpSession getSession(boolean create) {
313 return request.getSession(create);
314 }
315
316
317 public HttpSession getSession() {
318 return getSession(true);
319 }
320
321
322 public boolean isRequestedSessionIdValid() {
323 return request.isRequestedSessionIdValid();
324 }
325
326
327 public boolean isRequestedSessionIdFromCookie() {
328 return request.isRequestedSessionIdFromCookie();
329 }
330
331
332 public boolean isRequestedSessionIdFromURL() {
333 return request.isRequestedSessionIdFromURL();
334 }
335
336
337 public boolean isRequestedSessionIdFromUrl() {
338 return request.isRequestedSessionIdFromURL();
339 }
340
341
342 }