001
014
015 package com.liferay.util.bridges.struts;
016
017 import com.liferay.portal.kernel.servlet.ServletContextProvider;
018
019 import javax.portlet.GenericPortlet;
020 import javax.portlet.PortletContext;
021 import javax.portlet.PortletRequest;
022 import javax.portlet.PortletResponse;
023
024 import javax.servlet.ServletContext;
025 import javax.servlet.http.HttpServletRequest;
026 import javax.servlet.http.HttpServletResponse;
027
028
031 public class LiferayServletContextProviderWrapper
032 implements org.apache.portals.bridges.common.ServletContextProvider {
033
034 public ServletContext getServletContext(GenericPortlet portlet) {
035 ServletContextProvider provider = _getProvider(portlet);
036
037 return provider.getServletContext(portlet);
038 }
039
040 public HttpServletRequest getHttpServletRequest(
041 GenericPortlet portlet, PortletRequest portletRequest) {
042
043 ServletContextProvider provider = _getProvider(portlet);
044
045 return provider.getHttpServletRequest(portlet, portletRequest);
046 }
047
048 public HttpServletResponse getHttpServletResponse(
049 GenericPortlet portlet, PortletResponse portletResponse) {
050
051 ServletContextProvider provider = _getProvider(portlet);
052
053 return provider.getHttpServletResponse(portlet, portletResponse);
054 }
055
056 private ServletContextProvider _getProvider(GenericPortlet portlet) {
057 PortletContext portletContext = portlet.getPortletContext();
058
059 if (_provider == null) {
060 _provider = (ServletContextProvider)portletContext.getAttribute(
061 ServletContextProvider.STRUTS_BRIDGES_CONTEXT_PROVIDER);
062 }
063
064 return _provider;
065 }
066
067 private ServletContextProvider _provider;
068
069 }