1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.servlet;
16  
17  import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter;
18  
19  import java.io.IOException;
20  import java.io.Writer;
21  
22  import java.util.Enumeration;
23  
24  import javax.el.ELContext;
25  
26  import javax.servlet.Servlet;
27  import javax.servlet.ServletConfig;
28  import javax.servlet.ServletContext;
29  import javax.servlet.ServletException;
30  import javax.servlet.ServletRequest;
31  import javax.servlet.ServletResponse;
32  import javax.servlet.http.HttpSession;
33  import javax.servlet.jsp.ErrorData;
34  import javax.servlet.jsp.JspWriter;
35  import javax.servlet.jsp.PageContext;
36  import javax.servlet.jsp.tagext.BodyContent;
37  
38  /**
39   * <a href="PageContextWrapper.java.html"><b><i>View Source</i></b></a>
40   *
41   * @author Brian Wing Shun Chan
42   * @author Shuyang Zhou
43   */
44  public class PageContextWrapper extends PageContext {
45  
46      public PageContextWrapper(PageContext pageContext) {
47          _pageContext = pageContext;
48      }
49  
50      public Object findAttribute(String name) {
51          return _pageContext.findAttribute(name);
52      }
53  
54      public void forward(String relativeUrlPath)
55          throws IOException, ServletException {
56  
57          _pageContext.forward(relativeUrlPath);
58      }
59  
60      public Object getAttribute(String name) {
61          return _pageContext.getAttribute(name);
62      }
63  
64      public Object getAttribute(String name, int scope) {
65          return _pageContext.getAttribute(name, scope);
66      }
67  
68      public Enumeration<String> getAttributeNamesInScope(int scope) {
69          return _pageContext.getAttributeNamesInScope(scope);
70      }
71  
72      public int getAttributesScope(String name) {
73          return _pageContext.getAttributesScope(name);
74      }
75  
76      public ELContext getELContext() {
77          return _pageContext.getELContext();
78      }
79  
80      public ErrorData getErrorData() {
81          return super.getErrorData();
82      }
83  
84      public Exception getException() {
85          return _pageContext.getException();
86      }
87  
88      /**
89       * @deprecated
90       */
91      public javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() {
92          return _pageContext.getExpressionEvaluator();
93      }
94  
95      public JspWriter getOut() {
96          return new PipingJspWriter(_pageContext.getOut());
97      }
98  
99      public Object getPage() {
100         return _pageContext.getPage();
101     }
102 
103     public ServletRequest getRequest() {
104         return _pageContext.getRequest();
105     }
106 
107     public ServletResponse getResponse() {
108         return _pageContext.getResponse();
109     }
110 
111     public ServletConfig getServletConfig() {
112         return _pageContext.getServletConfig();
113     }
114 
115     public ServletContext getServletContext() {
116         return _pageContext.getServletContext();
117     }
118 
119     public HttpSession getSession() {
120         return _pageContext.getSession();
121     }
122 
123     /**
124      * @deprecated
125      */
126     public javax.servlet.jsp.el.VariableResolver getVariableResolver() {
127         return _pageContext.getVariableResolver();
128     }
129 
130     public PageContext getWrappedPageContext() {
131         return _pageContext;
132     }
133 
134     public void handlePageException(Exception e)
135         throws IOException, ServletException {
136 
137         _pageContext.handlePageException(e);
138     }
139 
140     public void handlePageException(Throwable t)
141         throws IOException, ServletException {
142 
143         _pageContext.handlePageException(t);
144     }
145 
146     public void include(String relativeUrlPath)
147         throws IOException, ServletException {
148 
149         _pageContext.include(relativeUrlPath);
150     }
151 
152     public void include(String relativeUrlPath, boolean flush)
153         throws IOException, ServletException {
154 
155         _pageContext.include(relativeUrlPath, flush);
156     }
157 
158     public void initialize(
159             Servlet servlet, ServletRequest request, ServletResponse response,
160             String errorPageURL, boolean needsSession, int bufferSize,
161             boolean autoFlush)
162         throws IllegalArgumentException, IllegalStateException, IOException {
163 
164         _pageContext.initialize(
165             servlet, request, response, errorPageURL, needsSession, bufferSize,
166             autoFlush);
167     }
168 
169     public JspWriter popBody() {
170         return _pageContext.popBody();
171     }
172 
173     public BodyContent pushBody() {
174         UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();
175 
176         BodyContent bodyContent = (BodyContent)_pageContext.pushBody(
177             unsyncStringWriter);
178 
179         return new BodyContentWrapper(bodyContent, unsyncStringWriter);
180     }
181 
182     public JspWriter pushBody(Writer writer) {
183         return _pageContext.pushBody(new PipingJspWriter(writer));
184     }
185 
186     public void release() {
187         _pageContext.release();
188     }
189 
190     public void removeAttribute(String name) {
191         _pageContext.removeAttribute(name);
192     }
193 
194     public void removeAttribute(String name, int scope) {
195         _pageContext.removeAttribute(name, scope);
196     }
197 
198     public void setAttribute(String name, Object value) {
199         _pageContext.setAttribute(name, value);
200     }
201 
202     public void setAttribute(String name, Object value, int scope) {
203         _pageContext.setAttribute(name, value, scope);
204     }
205 
206     private PageContext _pageContext;
207 
208 }