| LiferayServletContextProvider.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 */
19
20 package com.liferay.portal.apache.bridges.struts;
21
22 import com.liferay.portal.kernel.servlet.ServletContextProvider;
23 import com.liferay.portal.util.PortalUtil;
24 import com.liferay.portlet.PortletContextImpl;
25
26 import javax.portlet.GenericPortlet;
27 import javax.portlet.PortletRequest;
28 import javax.portlet.PortletResponse;
29
30 import javax.servlet.ServletContext;
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33
34 /**
35 * <a href="LiferayServletContextProvider.java.html"><b><i>View Source</i></b>
36 * </a>
37 *
38 * @author James Schopp
39 * @author Michael Young
40 *
41 */
42 public class LiferayServletContextProvider implements ServletContextProvider {
43
44 public ServletContext getServletContext(GenericPortlet portlet) {
45 PortletContextImpl portletContextImpl =
46 (PortletContextImpl)portlet.getPortletContext();
47
48 return getServletContext(portletContextImpl.getServletContext());
49 }
50
51 public ServletContext getServletContext(ServletContext servletContext) {
52 return new LiferayServletContext(servletContext);
53 }
54
55 public HttpServletRequest getHttpServletRequest(
56 GenericPortlet portlet, PortletRequest portletRequest) {
57
58 HttpServletRequest request = PortalUtil.getHttpServletRequest(
59 portletRequest);
60
61 return new LiferayStrutsRequestImpl(request);
62 }
63
64 public HttpServletResponse getHttpServletResponse(
65 GenericPortlet portlet, PortletResponse portletResponse) {
66
67 return PortalUtil.getHttpServletResponse(portletResponse);
68 }
69
70 }