KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tester > TesterHttpServletRequestWrapper


1 /*
2  * Copyright 1999, 2000 ,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.tester;
18
19
20 import java.io.*;
21 import java.security.Principal JavaDoc;
22 import java.util.*;
23 import javax.servlet.*;
24 import javax.servlet.http.*;
25
26 /**
27  * Tester request wrapper that logs all calls to the configured logger,
28  * before passing them on to the underlying request.
29  *
30  * @author Craig R. McClanahan
31  * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:57 $
32  */

33
34 public class TesterHttpServletRequestWrapper
35     extends HttpServletRequestWrapper {
36
37
38     // ------------------------------------------------------------ Constructor
39

40
41     /**
42      * Configure a new request wrapper.
43      *
44      * @param request The request we are wrapping
45      */

46     public TesterHttpServletRequestWrapper(HttpServletRequest request) {
47
48         super(request);
49
50     }
51
52
53     // --------------------------------------------------------- Public Methods
54

55
56     // For each public method, log the call and pass it to the wrapped response
57

58
59     public Object JavaDoc getAttribute(String JavaDoc name) {
60         StaticLogger.write("TesterHttpServletRequestWrapper.getAttribute()");
61         return (getRequest().getAttribute(name));
62     }
63
64
65     public Enumeration getAttributeNames() {
66         StaticLogger.write("TesterHttpServletRequestWrapper.getAttributeNames()");
67         return (getRequest().getAttributeNames());
68     }
69
70
71     public String JavaDoc getAuthType() {
72         StaticLogger.write("TesterHttpServletRequestWrapper.getAuthType()");
73         return (((HttpServletRequest) getRequest()).getAuthType());
74     }
75
76
77     public String JavaDoc getCharacterEncoding() {
78         StaticLogger.write("TesterHttpServletRequestWrapper.getCharacterEncoding()");
79         return (getRequest().getCharacterEncoding());
80     }
81
82
83     public int getContentLength() {
84         StaticLogger.write("TesterHttpServletRequestWrapper.getContentLength()");
85         return (getRequest().getContentLength());
86     }
87
88
89     public String JavaDoc getContentType() {
90         StaticLogger.write("TesterHttpServletRequestWrapper.getContentType()");
91         return (getRequest().getContentType());
92     }
93
94
95     public String JavaDoc getContextPath() {
96         StaticLogger.write("TesterHttpServletRequestWrapper.getContextPath()");
97         return (((HttpServletRequest) getRequest()).getContextPath());
98     }
99
100
101     public Cookie[] getCookies() {
102         StaticLogger.write("TesterHttpServletRequestWrapper.getCookies()");
103         return (((HttpServletRequest) getRequest()).getCookies());
104     }
105
106
107     public long getDateHeader(String JavaDoc name) {
108         StaticLogger.write("TesterHttpServletRequestWrapper.getDateHeader()");
109         return (((HttpServletRequest) getRequest()).getDateHeader(name));
110     }
111
112
113     public String JavaDoc getHeader(String JavaDoc name) {
114         StaticLogger.write("TesterHttpServletRequestWrapper.getHeader()");
115         return (((HttpServletRequest) getRequest()).getHeader(name));
116     }
117
118
119     public Enumeration getHeaders(String JavaDoc name) {
120         StaticLogger.write("TesterHttpServletRequestWrapper.getHeaders()");
121         return (((HttpServletRequest) getRequest()).getHeaders(name));
122     }
123
124
125     public Enumeration getHeaderNames() {
126         StaticLogger.write("TesterHttpServletRequestWrapper.getHeaderNames()");
127         return (((HttpServletRequest) getRequest()).getHeaderNames());
128     }
129
130
131     public ServletInputStream getInputStream() throws IOException {
132         StaticLogger.write("TesterHttpServletRequestWrapper.getInputStream()");
133         return (getRequest().getInputStream());
134     }
135
136
137     public int getIntHeader(String JavaDoc name) {
138         StaticLogger.write("TesterHttpServletRequestWrapper.getIntHeader()");
139         return (((HttpServletRequest) getRequest()).getIntHeader(name));
140     }
141
142
143     public Locale getLocale() {
144         StaticLogger.write("TesterHttpServletRequestWrapper.getLocale()");
145         return (getRequest().getLocale());
146     }
147
148
149     public Enumeration getLocales() {
150         StaticLogger.write("TesterHttpServletRequestWrapper.getLocales()");
151         return (getRequest().getLocales());
152     }
153
154
155     public String JavaDoc getMethod() {
156         StaticLogger.write("TesterHttpServletRequestWrapper.getMethod()");
157         return (((HttpServletRequest) getRequest()).getMethod());
158     }
159
160
161     public String JavaDoc getParameter(String JavaDoc name) {
162         StaticLogger.write("TesterHttpServletRequestWrapper.getParameter()");
163         return (getRequest().getParameter(name));
164     }
165
166
167     public Map getParameterMap() {
168         StaticLogger.write("TesterHttpServletRequestWrapper.getParameterMap()");
169         return (getRequest().getParameterMap());
170     }
171
172
173     public Enumeration getParameterNames() {
174         StaticLogger.write("TesterHttpServletRequestWrapper.getParameterNames()");
175         return (getRequest().getParameterNames());
176     }
177
178
179     public String JavaDoc[] getParameterValues(String JavaDoc name) {
180         StaticLogger.write("TesterHttpServletRequestWrapper.getParameterValues()");
181         return (getRequest().getParameterValues(name));
182     }
183
184
185     public String JavaDoc getPathInfo() {
186         StaticLogger.write("TesterHttpServletRequestWrapper.getPathInfo()");
187         return (((HttpServletRequest) getRequest()).getPathInfo());
188     }
189
190
191     public String JavaDoc getPathTranslated() {
192         StaticLogger.write("TesterHttpServletRequestWrapper.getPathTranslated()");
193         return (((HttpServletRequest) getRequest()).getPathTranslated());
194     }
195
196
197     public String JavaDoc getProtocol() {
198         StaticLogger.write("TesterHttpServletRequestWrapper.getProtocol()");
199         return (getRequest().getProtocol());
200     }
201
202
203     public String JavaDoc getQueryString() {
204         StaticLogger.write("TesterHttpServletRequestWrapper.getQueryString()");
205         return (((HttpServletRequest) getRequest()).getQueryString());
206     }
207
208
209     public BufferedReader getReader() throws IOException {
210         StaticLogger.write("TesterHttpServletRequestWrapper.getReader()");
211         return (getRequest().getReader());
212     }
213
214
215     public String JavaDoc getRealPath(String JavaDoc path) {
216         StaticLogger.write("TesterHttpServletRequestWrapper.getRealPath()");
217         return (getRequest().getRealPath(path));
218     }
219
220
221     public String JavaDoc getRemoteAddr() {
222         StaticLogger.write("TesterHttpServletRequestWrapper.getRemoteAddr()");
223         return (getRequest().getRemoteAddr());
224     }
225
226
227     public String JavaDoc getRemoteHost() {
228         StaticLogger.write("TesterHttpServletRequestWrapper.getRemoteHost()");
229         return (getRequest().getRemoteHost());
230     }
231
232
233     public String JavaDoc getRemoteUser() {
234         StaticLogger.write("TesterHttpServletRequestWrapper.getRemoteUser()");
235         return (((HttpServletRequest) getRequest()).getRemoteUser());
236     }
237
238
239     public RequestDispatcher getRequestDispatcher(String JavaDoc path) {
240         StaticLogger.write("TesterHttpServletRequestWrapper.getRequestDispatcher()");
241         return (getRequest().getRequestDispatcher(path));
242     }
243
244
245     public String JavaDoc getRequestURI() {
246         StaticLogger.write("TesterHttpServletRequestWrapper.getRequestURI()");
247         return (((HttpServletRequest) getRequest()).getRequestURI());
248     }
249
250
251     public StringBuffer JavaDoc getRequestURL() {
252         StaticLogger.write("TesterHttpServletRequestWrapper.getRequestURL()");
253         return (((HttpServletRequest) getRequest()).getRequestURL());
254     }
255
256
257     public String JavaDoc getRequestedSessionId() {
258         StaticLogger.write("TesterHttpServletRequestWrapper.getRequestedSessionId()");
259         return (((HttpServletRequest) getRequest()).getRequestedSessionId());
260     }
261
262
263     public String JavaDoc getScheme() {
264         StaticLogger.write("TesterHttpServletRequestWrapper.getScheme()");
265         return (getRequest().getScheme());
266     }
267
268
269     public String JavaDoc getServerName() {
270         StaticLogger.write("TesterHttpServletRequestWrapper.getServerName()");
271         return (getRequest().getServerName());
272     }
273
274
275     public int getServerPort() {
276         StaticLogger.write("TesterHttpServletRequestWrapper.getServerPort()");
277         return (getRequest().getServerPort());
278     }
279
280
281     public String JavaDoc getServletPath() {
282         StaticLogger.write("TesterHttpServletRequestWrapper.getServletPath()");
283         return (((HttpServletRequest) getRequest()).getServletPath());
284     }
285
286
287     public HttpSession getSession() {
288         StaticLogger.write("TesterHttpServletRequestWrapper.getSession()");
289         return (((HttpServletRequest) getRequest()).getSession());
290     }
291
292
293     public HttpSession getSession(boolean create) {
294         StaticLogger.write("TesterHttpServletRequestWrapper.getSession(b)");
295         return (((HttpServletRequest) getRequest()).getSession(create));
296     }
297
298
299     public Principal JavaDoc getUserPrincipal() {
300         StaticLogger.write("TesterHttpServletRequestWrapper.getUserPrincipal()");
301         return (((HttpServletRequest) getRequest()).getUserPrincipal());
302     }
303
304
305     public boolean isRequestedSessionIdFromCookie() {
306         StaticLogger.write("TesterHttpServletRequestWrapper.isRequestedSessionIdFromCookie()");
307         return (((HttpServletRequest) getRequest()).isRequestedSessionIdFromCookie());
308     }
309
310
311     public boolean isRequestedSessionIdFromUrl() {
312         StaticLogger.write("TesterHttpServletRequestWrapper.isRequestedSessionIdFromUrl()");
313         return (((HttpServletRequest) getRequest()).isRequestedSessionIdFromUrl());
314     }
315
316
317     public boolean isRequestedSessionIdFromURL() {
318         StaticLogger.write("TesterHttpServletRequestWrapper.isRequestedSessionIdFromURL()");
319         return (((HttpServletRequest) getRequest()).isRequestedSessionIdFromURL());
320     }
321
322
323     public boolean isRequestedSessionIdValid() {
324         StaticLogger.write("TesterHttpServletRequestWrapper.isRequestedSessionIdValid()");
325         return (((HttpServletRequest) getRequest()).isRequestedSessionIdValid());
326     }
327
328
329     public boolean isSecure() {
330         StaticLogger.write("TesterHttpServletRequestWrapper.isSecure()");
331         return (getRequest().isSecure());
332     }
333
334
335     public boolean isUserInRole(String JavaDoc role) {
336         StaticLogger.write("TesterHttpServletRequestWrapper.isUserInRole()");
337         return (((HttpServletRequest) getRequest()).isUserInRole(role));
338     }
339
340
341     public void removeAttribute(String JavaDoc name) {
342         StaticLogger.write("TesterHttpServletRequestWrapper.removeAttribute()");
343         getRequest().removeAttribute(name);
344     }
345
346
347     public void setAttribute(String JavaDoc name, Object JavaDoc value) {
348         StaticLogger.write("TesterHttpServletRequestWrapper.setAttribute()");
349         getRequest().setAttribute(name, value);
350     }
351
352
353     public void setCharacterEncoding(String JavaDoc enc)
354         throws UnsupportedEncodingException {
355         StaticLogger.write("TesterHttpServletRequestWrapper.setCharacterEncoding()");
356         getRequest().setCharacterEncoding(enc);
357     }
358
359
360
361
362
363 }
364
Popular Tags