KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jsp > PageContextWrapper


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.jsp;
31
32 import com.caucho.log.Log;
33 import com.caucho.server.connection.CauchoResponse;
34 import com.caucho.server.webapp.WebApp;
35 import com.caucho.util.FreeList;
36 import com.caucho.util.L10N;
37
38 import javax.servlet.ServletConfig JavaDoc;
39 import javax.servlet.ServletContext JavaDoc;
40 import javax.servlet.ServletRequest JavaDoc;
41 import javax.servlet.ServletResponse JavaDoc;
42 import javax.servlet.http.HttpServletRequest JavaDoc;
43 import javax.servlet.http.HttpSession JavaDoc;
44 import javax.servlet.jsp.ErrorData JavaDoc;
45 import javax.servlet.jsp.JspContext JavaDoc;
46 import javax.servlet.jsp.JspWriter JavaDoc;
47 import javax.servlet.jsp.el.ExpressionEvaluator JavaDoc;
48 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
49 import java.io.IOException JavaDoc;
50 import java.io.PrintWriter JavaDoc;
51 import java.io.Writer JavaDoc;
52 import java.util.logging.Logger JavaDoc;
53
54 public class PageContextWrapper extends PageContextImpl {
55   private static final Logger JavaDoc log = Log.open(PageContextWrapper.class);
56   static final L10N L = new L10N(PageContextWrapper.class);
57
58   private static final FreeList<PageContextWrapper> _freeList =
59     new FreeList<PageContextWrapper>(32);
60
61   private PageContextImpl _parent;
62
63   public void init(PageContextImpl parent)
64   {
65     _parent = parent;
66     clearAttributes();
67     setOut(parent.getOut());
68     _isFilled = true;
69   }
70
71   public static PageContextWrapper create(JspContext JavaDoc parent)
72   {
73     PageContextWrapper wrapper = _freeList.allocate();
74     if (wrapper == null)
75       wrapper = new PageContextWrapper();
76
77     wrapper.init((PageContextImpl) parent);
78
79     return wrapper;
80   }
81
82   /**
83    * Returns the underlying servlet for the page.
84    */

85   public Object JavaDoc getPage()
86   {
87     return _parent.getPage();
88   }
89
90   /**
91    * Returns the servlet request for the page.
92    */

93   public ServletRequest JavaDoc getRequest()
94   {
95     return _parent.getRequest();
96   }
97   
98   /**
99    * Returns the servlet response for the page.
100    */

101   public ServletResponse JavaDoc getResponse()
102   {
103     return _parent.getResponse();
104   }
105   
106   /**
107    * Returns the servlet response for the page.
108    */

109   public HttpServletRequest JavaDoc getCauchoRequest()
110   {
111     return _parent.getCauchoRequest();
112   }
113   
114   /**
115    * Returns the servlet response for the page.
116    */

117   public CauchoResponse getCauchoResponse()
118   {
119     return _parent.getCauchoResponse();
120   }
121
122   public HttpSession JavaDoc getSession()
123   {
124     return _parent.getSession();
125   }
126
127   public ServletConfig JavaDoc getServletConfig()
128   {
129     return _parent.getServletConfig();
130   }
131
132   /**
133    * Returns the page's servlet context.
134    */

135   public ServletContext JavaDoc getServletContext()
136   {
137     return _parent.getServletContext();
138   }
139
140   /**
141    * Returns the page's application.
142    */

143   public WebApp getApplication()
144   {
145     return _parent.getApplication();
146   }
147
148   /**
149    * Returns the page's error page.
150    */

151   public String JavaDoc getErrorPage()
152   {
153     return _parent.getErrorPage();
154   }
155
156   /**
157    * Sets the page's error page.
158    */

159   public void setErrorPage(String JavaDoc errorPage)
160   {
161     _parent.setErrorPage(errorPage);
162   }
163
164   /**
165    * Returns the Throwable stored by the error page.
166    */

167   public Throwable JavaDoc getThrowable()
168   {
169     return _parent.getThrowable();
170   }
171
172   /**
173    * Returns the error data
174    */

175   public ErrorData JavaDoc getErrorData()
176   {
177     return _parent.getErrorData();
178   }
179
180   /**
181    * Returns the variable resolver
182    */

183   public javax.servlet.jsp.el.VariableResolver JavaDoc getVariableResolver()
184   {
185     return _parent.getVariableResolver();
186   }
187
188   /**
189    * Returns the current out.
190    */

191   public JspWriter JavaDoc getOut()
192   {
193     return _parent.getOut();
194   }
195
196   /**
197    * Pushes the page body.
198    */

199   public BodyContent JavaDoc pushBody()
200   {
201     return _parent.pushBody();
202   }
203
204   /**
205    * Pushes the page body.
206    */

207   public JspWriter JavaDoc pushBody(Writer JavaDoc out)
208   {
209     return _parent.pushBody(out);
210   }
211
212   /**
213    * Pops the BodyContent from the JspWriter stack.
214    *
215    * @return the enclosing writer
216    */

217   public JspWriter JavaDoc popAndReleaseBody()
218     throws IOException JavaDoc
219   {
220     return _parent.popAndReleaseBody();
221   }
222
223   /**
224    * Pops the page body.
225    */

226   public JspWriter JavaDoc popBody()
227   {
228     return _parent.popBody();
229   }
230
231   public void releaseBody(BodyContentImpl out)
232     throws IOException JavaDoc
233   {
234     _parent.releaseBody(out);
235   }
236
237   /**
238    * Pops the BodyContent from the JspWriter stack.
239    *
240    * @param oldWriter the old writer
241    */

242   public JspWriter JavaDoc setWriter(JspWriter JavaDoc oldWriter)
243   {
244     return _parent.setWriter(oldWriter);
245   }
246
247   /**
248    * Returns the top writer.
249    */

250   public PrintWriter JavaDoc getTopWriter()
251     throws IOException JavaDoc
252   {
253     return _parent.getTopWriter();
254   }
255
256   /**
257    * Returns the expression evaluator
258    */

259   public ExpressionEvaluator JavaDoc getExpressionEvaluator()
260   {
261     return _parent.getExpressionEvaluator();
262   }
263
264   public static void free(PageContextWrapper wrapper)
265   {
266     _freeList.free(wrapper);
267   }
268 }
269
Popular Tags