KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.*;
22 import javax.servlet.*;
23 import javax.servlet.http.*;
24
25 /**
26  * Tester request wrapper that logs all calls to the configured logger,
27  * before passing them on to the underlying request.
28  *
29  * @author Craig R. McClanahan
30  * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:57 $
31  */

32
33 public class TesterServletRequestWrapper extends ServletRequestWrapper {
34
35
36     // ------------------------------------------------------------ Constructor
37

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

44     public TesterServletRequestWrapper(ServletRequest request) {
45
46         super(request);
47
48     }
49
50
51     // --------------------------------------------------------- Public Methods
52

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

56
57     public Object JavaDoc getAttribute(String JavaDoc name) {
58         StaticLogger.write("TesterServletRequestWrapper.getAttribute()");
59         return (getRequest().getAttribute(name));
60     }
61
62
63     public Enumeration getAttributeNames() {
64         StaticLogger.write("TesterServletRequestWrapper.getAttributeNames()");
65         return (getRequest().getAttributeNames());
66     }
67
68
69     public String JavaDoc getCharacterEncoding() {
70         StaticLogger.write("TesterServletRequestWrapper.getCharacterEncoding()");
71         return (getRequest().getCharacterEncoding());
72     }
73
74
75     public int getContentLength() {
76         StaticLogger.write("TesterServletRequestWrapper.getContentLength()");
77         return (getRequest().getContentLength());
78     }
79
80
81     public String JavaDoc getContentType() {
82         StaticLogger.write("TesterServletRequestWrapper.getContentType()");
83         return (getRequest().getContentType());
84     }
85
86
87     public ServletInputStream getInputStream() throws IOException {
88         StaticLogger.write("TesterServletRequestWrapper.getInputStream()");
89         return (getRequest().getInputStream());
90     }
91
92
93     public Locale getLocale() {
94         StaticLogger.write("TesterServletRequestWrapper.getLocale()");
95         return (getRequest().getLocale());
96     }
97
98
99     public Enumeration getLocales() {
100         StaticLogger.write("TesterServletRequestWrapper.getLocales()");
101         return (getRequest().getLocales());
102     }
103
104
105     public String JavaDoc getParameter(String JavaDoc name) {
106         StaticLogger.write("TesterServletRequestWrapper.getParameter()");
107         return (getRequest().getParameter(name));
108     }
109
110
111     public Map getParameterMap() {
112         StaticLogger.write("TesterServletRequestWrapper.getParameterMap()");
113         return (getRequest().getParameterMap());
114     }
115
116
117     public Enumeration getParameterNames() {
118         StaticLogger.write("TesterServletRequestWrapper.getParameterNames()");
119         return (getRequest().getParameterNames());
120     }
121
122
123     public String JavaDoc[] getParameterValues(String JavaDoc name) {
124         StaticLogger.write("TesterServletRequestWrapper.getParameterValues()");
125         return (getRequest().getParameterValues(name));
126     }
127
128
129     public String JavaDoc getProtocol() {
130         StaticLogger.write("TesterServletRequestWrapper.getProtocol()");
131         return (getRequest().getProtocol());
132     }
133
134
135     public BufferedReader getReader() throws IOException {
136         StaticLogger.write("TesterServletRequestWrapper.getReader()");
137         return (getRequest().getReader());
138     }
139
140
141     public String JavaDoc getRealPath(String JavaDoc path) {
142         StaticLogger.write("TesterServletRequestWrapper.getRealPath()");
143         return (getRequest().getRealPath(path));
144     }
145
146
147     public String JavaDoc getRemoteAddr() {
148         StaticLogger.write("TesterServletRequestWrapper.getRemoteAddr()");
149         return (getRequest().getRemoteAddr());
150     }
151
152
153     public String JavaDoc getRemoteHost() {
154         StaticLogger.write("TesterServletRequestWrapper.getRemoteHost()");
155         return (getRequest().getRemoteHost());
156     }
157
158
159     public RequestDispatcher getRequestDispatcher(String JavaDoc path) {
160         StaticLogger.write("TesterServletRequestWrapper.getRequestDispatcher()");
161         return (getRequest().getRequestDispatcher(path));
162     }
163
164
165     public String JavaDoc getScheme() {
166         StaticLogger.write("TesterServletRequestWrapper.getScheme()");
167         return (getRequest().getScheme());
168     }
169
170
171     public String JavaDoc getServerName() {
172         StaticLogger.write("TesterServletRequestWrapper.getServerName()");
173         return (getRequest().getServerName());
174     }
175
176
177     public int getServerPort() {
178         StaticLogger.write("TesterServletRequestWrapper.getServerPort()");
179         return (getRequest().getServerPort());
180     }
181
182
183     public boolean isSecure() {
184         StaticLogger.write("TesterServletRequestWrapper.isSecure()");
185         return (getRequest().isSecure());
186     }
187
188
189     public void removeAttribute(String JavaDoc name) {
190         StaticLogger.write("TesterServletRequestWrapper.removeAttribute()");
191         getRequest().removeAttribute(name);
192     }
193
194
195     public void setAttribute(String JavaDoc name, Object JavaDoc value) {
196         StaticLogger.write("TesterServletRequestWrapper.setAttribute()");
197         getRequest().setAttribute(name, value);
198     }
199
200
201     public void setCharacterEncoding(String JavaDoc enc)
202         throws UnsupportedEncodingException {
203         StaticLogger.write("TesterServletRequestWrapper.setCharacterEncoding()");
204         getRequest().setCharacterEncoding(enc);
205     }
206
207
208
209
210
211 }
212
Popular Tags