1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
13   */
14  
15  package com.liferay.portal.apache.bridges.struts;
16  
17  import com.liferay.portal.kernel.servlet.ServletContextProvider;
18  import com.liferay.portal.util.PortalUtil;
19  import com.liferay.portlet.PortletContextImpl;
20  
21  import javax.portlet.GenericPortlet;
22  import javax.portlet.PortletRequest;
23  import javax.portlet.PortletResponse;
24  
25  import javax.servlet.ServletContext;
26  import javax.servlet.http.HttpServletRequest;
27  import javax.servlet.http.HttpServletResponse;
28  
29  /**
30   * <a href="LiferayServletContextProvider.java.html"><b><i>View Source</i></b>
31   * </a>
32   *
33   * @author James Schopp
34   * @author Michael Young
35   */
36  public class LiferayServletContextProvider implements ServletContextProvider {
37  
38      public ServletContext getServletContext(GenericPortlet portlet) {
39          PortletContextImpl portletContextImpl =
40              (PortletContextImpl)portlet.getPortletContext();
41  
42          return getServletContext(portletContextImpl.getServletContext());
43      }
44  
45      public ServletContext getServletContext(ServletContext servletContext) {
46          return new LiferayServletContext(servletContext);
47      }
48  
49      public HttpServletRequest getHttpServletRequest(
50          GenericPortlet portlet, PortletRequest portletRequest) {
51  
52          HttpServletRequest request = PortalUtil.getHttpServletRequest(
53              portletRequest);
54  
55          return new LiferayStrutsRequestImpl(request);
56      }
57  
58      public HttpServletResponse getHttpServletResponse(
59          GenericPortlet portlet, PortletResponse portletResponse) {
60  
61          return PortalUtil.getHttpServletResponse(portletResponse);
62      }
63  
64  }