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 @Override
035 public HttpServletRequest getHttpServletRequest(
036 GenericPortlet portlet, PortletRequest portletRequest) {
037
038 ServletContextProvider provider = _getProvider(portlet);
039
040 return provider.getHttpServletRequest(portlet, portletRequest);
041 }
042
043 @Override
044 public HttpServletResponse getHttpServletResponse(
045 GenericPortlet portlet, PortletResponse portletResponse) {
046
047 ServletContextProvider provider = _getProvider(portlet);
048
049 return provider.getHttpServletResponse(portlet, portletResponse);
050 }
051
052 @Override
053 public ServletContext getServletContext(GenericPortlet portlet) {
054 ServletContextProvider provider = _getProvider(portlet);
055
056 return provider.getServletContext(portlet);
057 }
058
059 private ServletContextProvider _getProvider(GenericPortlet portlet) {
060 PortletContext portletContext = portlet.getPortletContext();
061
062 if (_provider == null) {
063 _provider = (ServletContextProvider)portletContext.getAttribute(
064 ServletContextProvider.STRUTS_BRIDGES_CONTEXT_PROVIDER);
065 }
066
067 return _provider;
068 }
069
070 private ServletContextProvider _provider;
071
072 }