cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl PortletAdapter.java
Date Fri, 06 Feb 2004 13:07:17 GMT
cziegeler    2004/02/06 05:07:17

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/impl
                        PortletPortalManager.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
                        PortletWindowAspect.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl
                        PortletAdapter.java
  Log:
  No direct cast from a component to it's implementation - this will not work with Fortress
:(
  
  Revision  Changes    Path
  1.3       +10 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortletPortalManager.java
  
  Index: PortletPortalManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortletPortalManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortletPortalManager.java	23 Jan 2004 12:34:31 -0000	1.2
  +++ PortletPortalManager.java	6 Feb 2004 13:07:17 -0000	1.3
  @@ -66,6 +66,7 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.environment.http.HttpEnvironment;
  +import org.apache.cocoon.portal.PortalManager;
   import org.apache.cocoon.portal.event.Event;
   import org.apache.cocoon.portal.event.EventManager;
   import org.apache.cocoon.portal.event.Filter;
  @@ -116,6 +117,10 @@
        */
       public void contextualize(Context context) throws ContextException {
           this.servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
  +        // we have to somehow pass this component down to other components!
  +        // This is ugly, but it's the only chance for sofisticated component containers
  +        // that wrap component implementations!
  +        this.servletConfig.getServletContext().setAttribute(PortalManager.ROLE, this);
           this.context = context;
       }
   
  @@ -146,6 +151,10 @@
               this.portletContainerEnvironment = null;
           } catch (Throwable t) {
               this.getLogger().error("Destruction failed!", t);
  +        }
  +        if ( this.servletConfig != null ) {
  +            this.servletConfig.getServletContext().removeAttribute(PortalManager.ROLE);
  +            this.servletConfig = null;
           }
       }
   
  
  
  
  1.2       +26 -16    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/PortletWindowAspect.java
  
  Index: PortletWindowAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/PortletWindowAspect.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletWindowAspect.java	22 Jan 2004 14:01:22 -0000	1.1
  +++ PortletWindowAspect.java	6 Feb 2004 13:07:17 -0000	1.2
  @@ -52,11 +52,14 @@
   
   import javax.portlet.PortletMode;
   import javax.portlet.WindowState;
  +import javax.servlet.ServletConfig;
   import javax.servlet.http.HttpServletRequest;
   
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.parameters.ParameterException;
   import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.service.ServiceException;
   import org.apache.cocoon.portal.PortalManager;
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
  @@ -69,6 +72,7 @@
   import org.apache.cocoon.portal.layout.impl.CopletLayout;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
   import org.apache.cocoon.portal.pluto.PortletURLProviderImpl;
  +import org.apache.cocoon.servlet.CocoonServlet;
   import org.apache.cocoon.xml.XMLUtils;
   import org.apache.pluto.om.portlet.PortletDefinition;
   import org.apache.pluto.om.window.PortletWindow;
  @@ -85,7 +89,24 @@
    * 
    * @version CVS $Id$
    */
  -public final class PortletWindowAspect extends AbstractAspect {
  +public final class PortletWindowAspect 
  +extends AbstractAspect 
  +implements Contextualizable {
  +
  +    /** The environment */
  +    protected PortletContainerEnvironment environment;
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
  +     */
  +    public void contextualize(Context context) throws ContextException {
  +        // now get the portal manager
  +        ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
  +        PortletPortalManager portalManager = (PortletPortalManager) servletConfig.getServletContext().getAttribute(PortalManager.ROLE);
  +        if ( portalManager != null ) {
  +            this.environment = portalManager.getPortletContainerEnvironment();
  +        }
  +    }
   
       /* (non-Javadoc)
        * @see org.apache.cocoon.portal.layout.renderer.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.RendererAspectContext,
org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
  @@ -118,19 +139,8 @@
               XMLUtils.createElement(contenthandler, "title", title);            
           
   
  -            PortletContainerEnvironment env = null;
  -            PortletPortalManager portalManager = null;
  -            try {
  -                portalManager = (PortletPortalManager) this.manager.lookup(PortalManager.ROLE);
  -                env = portalManager.getPortletContainerEnvironment();
  -            } catch (ServiceException ignore) {
  -                // if this fails something is *really* wrong, so we ignore it
  -            } finally {
  -                this.manager.release(portalManager);
  -            }
  -
  -            if ( env != null ) {
  -                InformationProviderService ips = (InformationProviderService) env.getContainerService(InformationProviderService.class);
  +            if ( this.environment != null ) {
  +                InformationProviderService ips = (InformationProviderService) this.environment.getContainerService(InformationProviderService.class);
                   DynamicInformationProvider dip = ips.getDynamicProvider((HttpServletRequest)
context.getObjectModel().get("portlet-request"));
                   
                   Event event;    
  
  
  
  1.4       +9 -18     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java
  
  Index: PortletAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PortletAdapter.java	27 Jan 2004 08:05:34 -0000	1.3
  +++ PortletAdapter.java	6 Feb 2004 13:07:17 -0000	1.4
  @@ -47,14 +47,13 @@
   
   import java.util.Map;
   
  +import javax.servlet.ServletConfig;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.environment.http.HttpEnvironment;
   import org.apache.cocoon.portal.PortalManager;
  @@ -67,6 +66,7 @@
   import org.apache.cocoon.portal.pluto.servlet.ServletRequestImpl;
   import org.apache.cocoon.portal.pluto.servlet.ServletResponseImpl;
   import org.apache.cocoon.portal.serialization.IncludingHTMLSerializer;
  +import org.apache.cocoon.servlet.CocoonServlet;
   import org.apache.cocoon.xml.AttributesImpl;
   import org.apache.pluto.PortletContainer;
   import org.apache.pluto.om.entity.PortletApplicationEntity;
  @@ -105,21 +105,12 @@
        */
       public void contextualize(Context context) throws ContextException {
           this.context = context;
  -    }
  -
  -    /* (non-Javadoc)
  -     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
  -     */
  -    public void service(ServiceManager manager) throws ServiceException {
  -        super.service(manager);
  -        PortletPortalManager portalManager = null;
  -        try {
  -            portalManager = (PortletPortalManager) this.manager.lookup(PortalManager.ROLE);
  -            this.portletContainer = portalManager.getPortletContainer();
  -            this.environment = portalManager.getPortletContainerEnvironment();
  -        } finally {
  -            this.manager.release(portalManager);
  -        }
  +        // now get the portal manager
  +        ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
  +        PortletPortalManager portalManager = (PortletPortalManager) servletConfig.getServletContext().getAttribute(PortalManager.ROLE);
  +        
  +        this.portletContainer = portalManager.getPortletContainer();
  +        this.environment = portalManager.getPortletContainerEnvironment();
       }
   
       /* (non-Javadoc)
  
  
  

Mime
View raw message