|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractPageContextWrapper.java | - | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* ====================================================================
|
|
3 |
*
|
|
4 |
* The Apache Software License, Version 1.1
|
|
5 |
*
|
|
6 |
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
|
|
7 |
* reserved.
|
|
8 |
*
|
|
9 |
* Redistribution and use in source and binary forms, with or without
|
|
10 |
* modification, are permitted provided that the following conditions
|
|
11 |
* are met:
|
|
12 |
*
|
|
13 |
* 1. Redistributions of source code must retain the above copyright
|
|
14 |
* notice, this list of conditions and the following disclaimer.
|
|
15 |
*
|
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer in
|
|
18 |
* the documentation and/or other materials provided with the
|
|
19 |
* distribution.
|
|
20 |
*
|
|
21 |
* 3. The end-user documentation included with the redistribution, if
|
|
22 |
* any, must include the following acknowlegement:
|
|
23 |
* "This product includes software developed by the
|
|
24 |
* Apache Software Foundation (http://www.apache.org/)."
|
|
25 |
* Alternately, this acknowlegement may appear in the software itself,
|
|
26 |
* if and wherever such third-party acknowlegements normally appear.
|
|
27 |
*
|
|
28 |
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
|
|
29 |
* Foundation" must not be used to endorse or promote products
|
|
30 |
* derived from this software without prior written permission. For
|
|
31 |
* written permission, please contact apache@apache.org.
|
|
32 |
*
|
|
33 |
* 5. Products derived from this software may not be called "Apache"
|
|
34 |
* nor may "Apache" appear in their names without prior written
|
|
35 |
* permission of the Apache Group.
|
|
36 |
*
|
|
37 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
38 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
39 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
40 |
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
41 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
42 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
43 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
44 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
45 |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
46 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
47 |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
48 |
* SUCH DAMAGE.
|
|
49 |
* ====================================================================
|
|
50 |
*
|
|
51 |
* This software consists of voluntary contributions made by many
|
|
52 |
* individuals on behalf of the Apache Software Foundation. For more
|
|
53 |
* information on the Apache Software Foundation, please see
|
|
54 |
* <http://www.apache.org/>.
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
package org.apache.cactus.server;
|
|
58 |
|
|
59 |
import java.io.IOException;
|
|
60 |
|
|
61 |
import java.util.Enumeration;
|
|
62 |
|
|
63 |
import javax.servlet.Servlet;
|
|
64 |
import javax.servlet.ServletConfig;
|
|
65 |
import javax.servlet.ServletContext;
|
|
66 |
import javax.servlet.ServletException;
|
|
67 |
import javax.servlet.ServletRequest;
|
|
68 |
import javax.servlet.ServletResponse;
|
|
69 |
import javax.servlet.http.HttpServletRequest;
|
|
70 |
import javax.servlet.http.HttpSession;
|
|
71 |
import javax.servlet.jsp.JspWriter;
|
|
72 |
import javax.servlet.jsp.PageContext;
|
|
73 |
import javax.servlet.jsp.tagext.BodyContent;
|
|
74 |
|
|
75 |
import org.apache.cactus.ServletURL;
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Abstract wrapper around <code>PageContext</code>. This class provides
|
|
79 |
* a common implementation of the wrapper for the different servlet API.
|
|
80 |
*
|
|
81 |
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
|
82 |
*
|
|
83 |
* @version $Id: AbstractPageContextWrapper.java,v 1.8 2003/05/26 11:45:22 cmlenz Exp $
|
|
84 |
*/
|
|
85 |
public abstract class AbstractPageContextWrapper extends PageContext |
|
86 |
{ |
|
87 |
/**
|
|
88 |
* The real page context
|
|
89 |
*/
|
|
90 |
protected PageContext originalPageContext;
|
|
91 |
|
|
92 |
/**
|
|
93 |
* The URL to simulate
|
|
94 |
*/
|
|
95 |
protected ServletURL url;
|
|
96 |
|
|
97 |
/**
|
|
98 |
* Construct an <code>PageContext</code> instance that delegates
|
|
99 |
* it's method calls to the page context object passed as parameter and
|
|
100 |
* that uses the URL passed as parameter to simulate a URL from which
|
|
101 |
* the request would come from.
|
|
102 |
*
|
|
103 |
* @param theOriginalPageContext the real page context
|
|
104 |
* @param theURL the URL to simulate or <code>null</code> if none
|
|
105 |
*/
|
|
106 | 0 |
public AbstractPageContextWrapper(PageContext theOriginalPageContext,
|
107 |
ServletURL theURL) |
|
108 |
{ |
|
109 | 0 |
this.originalPageContext = theOriginalPageContext;
|
110 | 0 |
this.url = theURL;
|
111 |
} |
|
112 |
|
|
113 |
// Modified overridden methods -------------------------------------------
|
|
114 |
|
|
115 |
/**
|
|
116 |
* @return the Cactus wrapped servlet request that knows about the
|
|
117 |
* simulated URL
|
|
118 |
*/
|
|
119 | 0 |
public ServletRequest getRequest()
|
120 |
{ |
|
121 |
// Note: we only manage HttpServletRequest here
|
|
122 | 0 |
return new HttpServletRequestWrapper( |
123 |
(HttpServletRequest) this.originalPageContext.getRequest(),
|
|
124 |
this.url);
|
|
125 |
} |
|
126 |
|
|
127 |
/**
|
|
128 |
* @return the Cactus wrapped servlet config
|
|
129 |
*/
|
|
130 | 0 |
public ServletConfig getServletConfig()
|
131 |
{ |
|
132 | 0 |
return new ServletConfigWrapper( |
133 |
this.originalPageContext.getServletConfig());
|
|
134 |
} |
|
135 |
|
|
136 |
/**
|
|
137 |
* @return the Cactus wrapped servlet context
|
|
138 |
*/
|
|
139 | 0 |
public ServletContext getServletContext()
|
140 |
{ |
|
141 | 0 |
return new ServletContextWrapper( |
142 |
this.originalPageContext.getServletContext());
|
|
143 |
} |
|
144 |
|
|
145 |
// Unmodified overridden methods -----------------------------------------
|
|
146 |
|
|
147 |
/**
|
|
148 |
* @see PageContext#findAttribute(String)
|
|
149 |
*/
|
|
150 | 0 |
public Object findAttribute(String theName)
|
151 |
{ |
|
152 | 0 |
return this.originalPageContext.findAttribute(theName); |
153 |
} |
|
154 |
|
|
155 |
/**
|
|
156 |
* @see PageContext#forward(String)
|
|
157 |
*/
|
|
158 | 0 |
public void forward(String theRelativeURLPath) throws ServletException, |
159 |
IOException |
|
160 |
{ |
|
161 | 0 |
this.originalPageContext.forward(theRelativeURLPath);
|
162 |
} |
|
163 |
|
|
164 |
/**
|
|
165 |
* @see PageContext#getAttribute(String)
|
|
166 |
*/
|
|
167 | 0 |
public Object getAttribute(String theName)
|
168 |
{ |
|
169 | 0 |
return this.originalPageContext.getAttribute(theName); |
170 |
} |
|
171 |
|
|
172 |
/**
|
|
173 |
* @see PageContext#getAttribute(String, int)
|
|
174 |
*/
|
|
175 | 0 |
public Object getAttribute(String theName, int theScope) |
176 |
{ |
|
177 | 0 |
return this.originalPageContext.getAttribute(theName, theScope); |
178 |
} |
|
179 |
|
|
180 |
/**
|
|
181 |
* @see PageContext#getAttributeNamesInScope(int)
|
|
182 |
*/
|
|
183 | 0 |
public Enumeration getAttributeNamesInScope(int theScope) |
184 |
{ |
|
185 | 0 |
return this.originalPageContext.getAttributeNamesInScope(theScope); |
186 |
} |
|
187 |
|
|
188 |
/**
|
|
189 |
* @see PageContext#getAttributesScope(String)
|
|
190 |
*/
|
|
191 | 0 |
public int getAttributesScope(String theName) |
192 |
{ |
|
193 | 0 |
return this.originalPageContext.getAttributesScope(theName); |
194 |
} |
|
195 |
|
|
196 |
/**
|
|
197 |
* @see PageContext#getException()
|
|
198 |
*/
|
|
199 | 0 |
public Exception getException()
|
200 |
{ |
|
201 | 0 |
return this.originalPageContext.getException(); |
202 |
} |
|
203 |
|
|
204 |
/**
|
|
205 |
* @see PageContext#getOut()
|
|
206 |
*/
|
|
207 | 0 |
public JspWriter getOut()
|
208 |
{ |
|
209 | 0 |
return this.originalPageContext.getOut(); |
210 |
} |
|
211 |
|
|
212 |
/**
|
|
213 |
* @see PageContext#getPage()
|
|
214 |
*/
|
|
215 | 0 |
public Object getPage()
|
216 |
{ |
|
217 | 0 |
return this.originalPageContext.getPage(); |
218 |
} |
|
219 |
|
|
220 |
/**
|
|
221 |
* @see PageContext#getResponse()
|
|
222 |
*/
|
|
223 | 0 |
public ServletResponse getResponse()
|
224 |
{ |
|
225 | 0 |
return this.originalPageContext.getResponse(); |
226 |
} |
|
227 |
|
|
228 |
/**
|
|
229 |
* @see PageContext#getSession()
|
|
230 |
*/
|
|
231 | 0 |
public HttpSession getSession()
|
232 |
{ |
|
233 | 0 |
return this.originalPageContext.getSession(); |
234 |
} |
|
235 |
|
|
236 |
/**
|
|
237 |
* @see PageContext#handlePageException(Exception)
|
|
238 |
*/
|
|
239 | 0 |
public void handlePageException(Exception theException) |
240 |
throws ServletException, IOException
|
|
241 |
{ |
|
242 | 0 |
this.originalPageContext.handlePageException(theException);
|
243 |
} |
|
244 |
|
|
245 |
/**
|
|
246 |
* @see PageContext#include(String)
|
|
247 |
*/
|
|
248 | 0 |
public void include(String theRelativeURLPath) throws ServletException, |
249 |
IOException |
|
250 |
{ |
|
251 | 0 |
this.originalPageContext.include(theRelativeURLPath);
|
252 |
} |
|
253 |
|
|
254 |
/**
|
|
255 |
* @see PageContext#initialize
|
|
256 |
*/
|
|
257 | 0 |
public void initialize(Servlet theServlet, ServletRequest theRequest, |
258 |
ServletResponse theResponse, String theErrorPageURL, |
|
259 |
boolean isSessionNeeded, int theBufferSize, boolean isAutoFlush) |
|
260 |
throws IOException, IllegalStateException, IllegalArgumentException
|
|
261 |
{ |
|
262 | 0 |
this.originalPageContext.initialize(theServlet, theRequest,
|
263 |
theResponse, theErrorPageURL, isSessionNeeded, theBufferSize, |
|
264 |
isAutoFlush); |
|
265 |
} |
|
266 |
|
|
267 |
/**
|
|
268 |
* @see PageContext#popBody()
|
|
269 |
*/
|
|
270 | 0 |
public JspWriter popBody()
|
271 |
{ |
|
272 | 0 |
return this.originalPageContext.popBody(); |
273 |
} |
|
274 |
|
|
275 |
/**
|
|
276 |
* @see PageContext#pushBody()
|
|
277 |
*/
|
|
278 | 0 |
public BodyContent pushBody()
|
279 |
{ |
|
280 | 0 |
return this.originalPageContext.pushBody(); |
281 |
} |
|
282 |
|
|
283 |
/**
|
|
284 |
* @see PageContext#release()
|
|
285 |
*/
|
|
286 | 0 |
public void release() |
287 |
{ |
|
288 | 0 |
this.originalPageContext.release();
|
289 |
} |
|
290 |
|
|
291 |
/**
|
|
292 |
* @see PageContext#removeAttribute(String)
|
|
293 |
*/
|
|
294 | 0 |
public void removeAttribute(String theName) |
295 |
{ |
|
296 | 0 |
this.originalPageContext.removeAttribute(theName);
|
297 |
} |
|
298 |
|
|
299 |
/**
|
|
300 |
* @see PageContext#removeAttribute(String, int)
|
|
301 |
*/
|
|
302 | 0 |
public void removeAttribute(String theName, int theScope) |
303 |
{ |
|
304 | 0 |
this.originalPageContext.removeAttribute(theName, theScope);
|
305 |
} |
|
306 |
|
|
307 |
/**
|
|
308 |
* @see PageContext#setAttribute(String, Object)
|
|
309 |
*/
|
|
310 | 0 |
public void setAttribute(String theName, Object theAttribute) |
311 |
{ |
|
312 | 0 |
this.originalPageContext.setAttribute(theName, theAttribute);
|
313 |
} |
|
314 |
|
|
315 |
/**
|
|
316 |
* @see PageContext#setAttribute(String, Object)
|
|
317 |
*/
|
|
318 | 0 |
public void setAttribute(String theName, Object theAttribute, int theScope) |
319 |
{ |
|
320 | 0 |
this.originalPageContext.setAttribute(theName, theAttribute, theScope);
|
321 |
} |
|
322 |
} |
|
323 |
|
|