1 16 package org.apache.cocoon.portal.pluto; 17 18 import javax.servlet.http.HttpServletRequest ; 19 20 import org.apache.avalon.framework.context.Context; 21 import org.apache.avalon.framework.context.ContextException; 22 import org.apache.avalon.framework.context.Contextualizable; 23 import org.apache.avalon.framework.service.ServiceException; 24 import org.apache.avalon.framework.service.ServiceManager; 25 import org.apache.avalon.framework.service.Serviceable; 26 import org.apache.cocoon.components.ContextHelper; 27 import org.apache.cocoon.portal.pluto.om.PortletDefinitionRegistry; 28 import org.apache.pluto.services.PortletContainerEnvironment; 29 import org.apache.pluto.services.information.DynamicInformationProvider; 30 import org.apache.pluto.services.information.InformationProviderService; 31 import org.apache.pluto.services.information.StaticInformationProvider; 32 33 40 public class InformationProviderServiceImpl 41 implements InformationProviderService, PortletContainerEnabled, Serviceable, Contextualizable { 42 43 44 protected ServiceManager manager; 45 46 47 protected PortletContainerEnvironmentImpl portletContainerEnvironment; 48 49 50 protected StaticInformationProvider staticProvider; 51 52 53 protected PortalContextProviderImpl provider; 54 55 56 protected Context context; 57 58 final static protected String dynamicProviderRole= InformationProviderServiceImpl.class.getName(); 59 60 63 public void setPortletContainerEnvironment(PortletContainerEnvironment env) { 64 this.portletContainerEnvironment = (PortletContainerEnvironmentImpl)env; 65 } 66 67 70 public StaticInformationProvider getStaticProvider() { 71 if ( this.staticProvider == null ) { 72 this.staticProvider = new StaticInformationProviderImpl(this.getPortalContextProvider(), 73 (PortletDefinitionRegistry)this.portletContainerEnvironment.getContainerService(PortletDefinitionRegistry.class)); 74 } 75 return this.staticProvider; 76 } 77 78 81 public DynamicInformationProvider getDynamicProvider(HttpServletRequest request) { 82 DynamicInformationProvider dynProvider = (DynamicInformationProvider)request.getAttribute(dynamicProviderRole); 83 84 if (dynProvider == null) { 85 dynProvider = new DynamicInformationProviderImpl(this.manager, 86 this.getPortalContextProvider()); 87 request.setAttribute(dynamicProviderRole, dynProvider); 88 } 89 90 return dynProvider; 91 } 92 93 94 97 public void contextualize(Context context) throws ContextException { 98 this.context = context; 99 } 100 101 104 public void service(ServiceManager manager) throws ServiceException { 105 this.manager = manager; 106 } 107 108 112 protected PortalContextProviderImpl getPortalContextProvider() { 113 if ( this.provider == null ) { 114 this.provider = new PortalContextProviderImpl(ContextHelper.getObjectModel(context)); 115 } 116 return this.provider; 117 } 118 119 } 120 | Popular Tags |