KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cactus > server > AbstractPageContextWrapper


1 /*
2  * ========================================================================
3  *
4  * Copyright 2001-2003 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * ========================================================================
19  */

20 package org.apache.cactus.server;
21
22 import java.io.IOException JavaDoc;
23
24 import java.util.Enumeration JavaDoc;
25
26 import javax.servlet.Servlet JavaDoc;
27 import javax.servlet.ServletConfig JavaDoc;
28 import javax.servlet.ServletContext JavaDoc;
29 import javax.servlet.ServletException JavaDoc;
30 import javax.servlet.ServletRequest JavaDoc;
31 import javax.servlet.ServletResponse JavaDoc;
32 import javax.servlet.http.HttpServletRequest JavaDoc;
33 import javax.servlet.http.HttpSession JavaDoc;
34 import javax.servlet.jsp.JspWriter JavaDoc;
35 import javax.servlet.jsp.PageContext JavaDoc;
36 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
37
38 import org.apache.cactus.ServletURL;
39
40 /**
41  * Abstract wrapper around <code>PageContext</code>. This class provides
42  * a common implementation of the wrapper for the different servlet API.
43  *
44  * @version $Id: AbstractPageContextWrapper.java,v 1.1 2004/05/22 11:34:48 vmassol Exp $
45  */

46 public abstract class AbstractPageContextWrapper extends PageContext JavaDoc
47 {
48     /**
49      * The real page context
50      */

51     protected PageContext JavaDoc originalPageContext;
52
53     /**
54      * The URL to simulate
55      */

56     protected ServletURL url;
57
58     /**
59      * Construct an <code>PageContext</code> instance that delegates
60      * it's method calls to the page context object passed as parameter and
61      * that uses the URL passed as parameter to simulate a URL from which
62      * the request would come from.
63      *
64      * @param theOriginalPageContext the real page context
65      * @param theURL the URL to simulate or <code>null</code> if none
66      */

67     public AbstractPageContextWrapper(PageContext JavaDoc theOriginalPageContext,
68         ServletURL theURL)
69     {
70         this.originalPageContext = theOriginalPageContext;
71         this.url = theURL;
72     }
73
74     // Modified overridden methods -------------------------------------------
75

76     /**
77      * @return the Cactus wrapped servlet request that knows about the
78      * simulated URL
79      */

80     public ServletRequest JavaDoc getRequest()
81     {
82         // Note: we only manage HttpServletRequest here
83
return new HttpServletRequestWrapper(
84             (HttpServletRequest JavaDoc) this.originalPageContext.getRequest(),
85             this.url);
86     }
87
88     /**
89      * @return the Cactus wrapped servlet config
90      */

91     public ServletConfig JavaDoc getServletConfig()
92     {
93         return new ServletConfigWrapper(
94             this.originalPageContext.getServletConfig());
95     }
96
97     /**
98      * @return the Cactus wrapped servlet context
99      */

100     public ServletContext JavaDoc getServletContext()
101     {
102         return new ServletContextWrapper(
103             this.originalPageContext.getServletContext());
104     }
105
106     // Unmodified overridden methods -----------------------------------------
107

108     /**
109      * @see PageContext#findAttribute(String)
110      */

111     public Object JavaDoc findAttribute(String JavaDoc theName)
112     {
113         return this.originalPageContext.findAttribute(theName);
114     }
115
116     /**
117      * @see PageContext#forward(String)
118      */

119     public void forward(String JavaDoc theRelativeURLPath) throws ServletException JavaDoc,
120         IOException JavaDoc
121     {
122         this.originalPageContext.forward(theRelativeURLPath);
123     }
124
125     /**
126      * @see PageContext#getAttribute(String)
127      */

128     public Object JavaDoc getAttribute(String JavaDoc theName)
129     {
130         return this.originalPageContext.getAttribute(theName);
131     }
132
133     /**
134      * @see PageContext#getAttribute(String, int)
135      */

136     public Object JavaDoc getAttribute(String JavaDoc theName, int theScope)
137     {
138         return this.originalPageContext.getAttribute(theName, theScope);
139     }
140
141     /**
142      * @see PageContext#getAttributeNamesInScope(int)
143      */

144     public Enumeration JavaDoc getAttributeNamesInScope(int theScope)
145     {
146         return this.originalPageContext.getAttributeNamesInScope(theScope);
147     }
148
149     /**
150      * @see PageContext#getAttributesScope(String)
151      */

152     public int getAttributesScope(String JavaDoc theName)
153     {
154         return this.originalPageContext.getAttributesScope(theName);
155     }
156
157     /**
158      * @see PageContext#getException()
159      */

160     public Exception JavaDoc getException()
161     {
162         return this.originalPageContext.getException();
163     }
164
165     /**
166      * @see PageContext#getOut()
167      */

168     public JspWriter JavaDoc getOut()
169     {
170         return this.originalPageContext.getOut();
171     }
172
173     /**
174      * @see PageContext#getPage()
175      */

176     public Object JavaDoc getPage()
177     {
178         return this.originalPageContext.getPage();
179     }
180
181     /**
182      * @see PageContext#getResponse()
183      */

184     public ServletResponse JavaDoc getResponse()
185     {
186         return this.originalPageContext.getResponse();
187     }
188
189     /**
190      * @see PageContext#getSession()
191      */

192     public HttpSession JavaDoc getSession()
193     {
194         return this.originalPageContext.getSession();
195     }
196
197     /**
198      * @see PageContext#handlePageException(Exception)
199      */

200     public void handlePageException(Exception JavaDoc theException)
201         throws ServletException JavaDoc, IOException JavaDoc
202     {
203         this.originalPageContext.handlePageException(theException);
204     }
205
206     /**
207      * @see PageContext#include(String)
208      */

209     public void include(String JavaDoc theRelativeURLPath) throws ServletException JavaDoc,
210         IOException JavaDoc
211     {
212         this.originalPageContext.include(theRelativeURLPath);
213     }
214
215     /**
216      * @see PageContext#initialize
217      */

218     public void initialize(Servlet JavaDoc theServlet, ServletRequest JavaDoc theRequest,
219         ServletResponse JavaDoc theResponse, String JavaDoc theErrorPageURL,
220         boolean isSessionNeeded, int theBufferSize, boolean isAutoFlush)
221         throws IOException JavaDoc, IllegalStateException JavaDoc, IllegalArgumentException JavaDoc
222     {
223         this.originalPageContext.initialize(theServlet, theRequest,
224             theResponse, theErrorPageURL, isSessionNeeded, theBufferSize,
225             isAutoFlush);
226     }
227
228     /**
229      * @see PageContext#popBody()
230      */

231     public JspWriter JavaDoc popBody()
232     {
233         return this.originalPageContext.popBody();
234     }
235
236     /**
237      * @see PageContext#pushBody()
238      */

239     public BodyContent JavaDoc pushBody()
240     {
241         return this.originalPageContext.pushBody();
242     }
243
244     /**
245      * @see PageContext#release()
246      */

247     public void release()
248     {
249         this.originalPageContext.release();
250     }
251
252     /**
253      * @see PageContext#removeAttribute(String)
254      */

255     public void removeAttribute(String JavaDoc theName)
256     {
257         this.originalPageContext.removeAttribute(theName);
258     }
259
260     /**
261      * @see PageContext#removeAttribute(String, int)
262      */

263     public void removeAttribute(String JavaDoc theName, int theScope)
264     {
265         this.originalPageContext.removeAttribute(theName, theScope);
266     }
267
268     /**
269      * @see PageContext#setAttribute(String, Object)
270      */

271     public void setAttribute(String JavaDoc theName, Object JavaDoc theAttribute)
272     {
273         this.originalPageContext.setAttribute(theName, theAttribute);
274     }
275
276     /**
277      * @see PageContext#setAttribute(String, Object)
278      */

279     public void setAttribute(String JavaDoc theName, Object JavaDoc theAttribute, int theScope)
280     {
281         this.originalPageContext.setAttribute(theName, theAttribute, theScope);
282     }
283 }
284
Popular Tags