cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r226363 - in /cocoon/blocks/portal/trunk: WEB-INF/xconf/ java/org/apache/cocoon/portal/ java/org/apache/cocoon/portal/coplet/adapter/impl/ java/org/apache/cocoon/portal/impl/ java/org/apache/cocoon/portal/layout/renderer/aspect/impl/
Date Fri, 29 Jul 2005 12:36:29 GMT
Author: cziegeler
Date: Fri Jul 29 05:36:18 2005
New Revision: 226363

URL: http://svn.apache.org/viewcvs?rev=226363&view=rev
Log:
Move all portlet related code to a single place

Removed:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortletPortalManagerAspect.java
Modified:
    cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalComponentManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerAspectChain.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/PortletWindowAspect.java

Modified: cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf?rev=226363&r1=226362&r2=226363&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf (original)
+++ cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf Fri Jul 29 05:36:18 2005
@@ -59,8 +59,7 @@
   <!-- Portal Manager Aspect Configuration -->
   <component class="org.apache.cocoon.core.container.DefaultServiceSelector"
              role="org.apache.cocoon.portal.PortalManagerAspectSelector">
-    <!-- This aspect activates the JSR-168 support. -->
-    <aspect logger="portal" name="portlet" class="org.apache.cocoon.portal.impl.PortletPortalManagerAspect"/>
+      <!--  You can add own aspects here. -->
   </component>
 
   <component class="org.apache.cocoon.portal.event.impl.DefaultEventManager" logger="portal"
role="org.apache.cocoon.portal.event.EventManager">
@@ -110,7 +109,7 @@
              logger="portal" role="org.apache.cocoon.portal.PortalManager">
     <aspects>
       <!-- JSR-168 support: -->
-      <aspect type="portlet"/>
+      <aspect adapter="portlet"/>
     </aspects>
   </component>
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalComponentManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalComponentManager.java?rev=226363&r1=226362&r2=226363&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalComponentManager.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalComponentManager.java Fri
Jul 29 05:36:18 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.portal;
 
+import org.apache.cocoon.core.Core;
 import org.apache.cocoon.portal.coplet.CopletFactory;
 import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.layout.LayoutFactory;
@@ -72,4 +73,10 @@
      * @since 2.1.8
      */
     PortalManager getPortalManager();
+
+    /**
+     * Get the Cocoon core object.
+     * @since 2.2
+     */
+    Core getCore();
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java?rev=226363&r1=226362&r2=226363&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/PortletAdapter.java
Fri Jul 29 05:36:18 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004,2004 The Apache Software Foundation.
+ * Copyright 2004,2004-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,36 @@
 package org.apache.cocoon.portal.coplet.adapter.impl;
 
 import java.util.Map;
+import java.util.Properties;
 
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
 import javax.servlet.ServletConfig;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.container.ContainerUtil;
 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.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+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.PortalManagerAspect;
+import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
+import org.apache.cocoon.portal.PortalManagerAspectRenderContext;
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
-import org.apache.cocoon.portal.impl.PortletPortalManagerAspect;
+import org.apache.cocoon.portal.event.EventManager;
+import org.apache.cocoon.portal.event.Receiver;
+import org.apache.cocoon.portal.pluto.PortletContainerEnvironmentImpl;
+import org.apache.cocoon.portal.pluto.PortletURLProviderImpl;
 import org.apache.cocoon.portal.pluto.om.PortletDefinitionRegistry;
 import org.apache.cocoon.portal.pluto.om.PortletEntityListImpl;
 import org.apache.cocoon.portal.pluto.om.PortletWindowImpl;
@@ -38,6 +56,8 @@
 import org.apache.cocoon.servlet.CocoonServlet;
 import org.apache.cocoon.xml.AttributesImpl;
 import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.PortletContainerImpl;
 import org.apache.pluto.om.entity.PortletApplicationEntity;
 import org.apache.pluto.om.entity.PortletEntity;
 import org.apache.pluto.om.window.PortletWindow;
@@ -45,6 +65,9 @@
 import org.apache.pluto.om.window.PortletWindowList;
 import org.apache.pluto.om.window.PortletWindowListCtrl;
 import org.apache.pluto.services.PortletContainerEnvironment;
+import org.apache.pluto.services.information.DynamicInformationProvider;
+import org.apache.pluto.services.information.InformationProviderService;
+import org.apache.pluto.services.information.PortletActionProvider;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -58,29 +81,34 @@
  */
 public class PortletAdapter 
     extends AbstractCopletAdapter
-    implements Contextualizable {
+    implements Contextualizable, Initializable, PortalManagerAspect, Receiver, Disposable
{
 	
+    protected final ThreadLocal copletInstanceData = new InheritableThreadLocal();
+
     /** The avalon context */
     protected Context context;
     
-    /** The portlet container */    
+    /** The servlet configuration for pluto */
+    protected ServletConfig servletConfig;
+
+    /** The Portlet Container */
     protected PortletContainer portletContainer;
-    
-    /** The portlet container environment */
-    protected PortletContainerEnvironment environment;
-    
-    /* (non-Javadoc)
+
+    /** The Portlet Container environment */
+    protected PortletContainerEnvironmentImpl portletContainerEnvironment;
+
+    /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
     public void contextualize(Context context) throws ContextException {
         this.context = context;
         try {
-            // now get the portal manager
-            ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
-            PortletPortalManagerAspect portalManager = (PortletPortalManagerAspect) servletConfig.getServletContext().getAttribute(PortletPortalManagerAspect.class.getName());
-            
-            this.portletContainer = portalManager.getPortletContainer();
-            this.environment = portalManager.getPortletContainerEnvironment();
+            // TODO - we could lookup the component from the adapter selector
+            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(PortletAdapter.class.getName(),
this);
         } catch (ContextException ignore) {
             // we ignore the context exception
             // this avoids startup errors if the portal is configured for the CLI
@@ -98,7 +126,7 @@
         if ( this.portletContainer == null ) {
             return;
         }
-        PortletDefinitionRegistry registry = (PortletDefinitionRegistry) environment.getContainerService(PortletDefinitionRegistry.class);
+        PortletDefinitionRegistry registry = (PortletDefinitionRegistry) portletContainerEnvironment.getContainerService(PortletDefinitionRegistry.class);
         
         final String portletEntityId = (String) getConfiguration(coplet, "portlet");   
         
@@ -124,7 +152,7 @@
                 objectModel.put("portlet-request",  req);                
             }
             final HttpServletResponse res = (HttpServletResponse) objectModel.get("portlet-response");
-            PortletPortalManagerAspect.copletInstanceData.set(coplet);
+            this.copletInstanceData.set(coplet);
             try {
                 this.portletContainer.portletLoad(portletWindow, req.getRequest(portletWindow),
 
                                                   res);
@@ -134,7 +162,7 @@
                 coplet.removeTemporaryAttribute("window");
                 ((PortletEntityListImpl)pae.getPortletEntityList()).remove(portletEntity);
             } finally {
-                PortletPortalManagerAspect.copletInstanceData.set(null);
+                this.copletInstanceData.set(null);
             }
         }
     }
@@ -161,7 +189,7 @@
             final Map objectModel = ContextHelper.getObjectModel(this.context);
             final ServletRequestImpl  req = (ServletRequestImpl) objectModel.get("portlet-request");
             final HttpServletResponse res = (HttpServletResponse) objectModel.get("portlet-response");
-            PortletPortalManagerAspect.copletInstanceData.set(coplet);
+            this.copletInstanceData.set(coplet);
             
             // TODO - for parallel processing we have to clone the response!
             this.portletContainer.renderPortlet(window, req.getRequest(window), res);
@@ -182,11 +210,11 @@
         } catch (Exception e) {
             throw new SAXException(e);
         } finally {
-            PortletPortalManagerAspect.copletInstanceData.set(null);            
+            this.copletInstanceData.set(null);            
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.coplet.adapter.CopletAdapter#logout(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void logout(CopletInstanceData coplet) {
@@ -197,10 +225,195 @@
         PortletWindow window = (PortletWindow)coplet.getTemporaryAttribute("window");
         if ( window != null ) {
             coplet.removeTemporaryAttribute("window");
-            PortletDefinitionRegistry registry = (PortletDefinitionRegistry) environment.getContainerService(PortletDefinitionRegistry.class);
+            PortletDefinitionRegistry registry = (PortletDefinitionRegistry) portletContainerEnvironment.getContainerService(PortletDefinitionRegistry.class);
         
             PortletApplicationEntity pae = registry.getPortletApplicationEntityList().get(ObjectIDImpl.createFromString("cocoon"));
             ((PortletEntityListImpl)pae.getPortletEntityList()).remove(window.getPortletEntity());
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        super.service(manager);
+        EventManager eventManager = null;
+        try {
+            eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
+            eventManager.subscribe(this);
+        } finally {
+            this.manager.release(eventManager);
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if ( this.manager != null ) {
+            EventManager eventManager = null;
+            try {
+                eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
+                eventManager.unsubscribe(this);
+            } catch (Exception ignore) {
+                // let's ignore it
+            } finally {
+                this.manager.release(eventManager);
+            }
+            this.manager = null;
+        }
+        try {
+            if (this.portletContainer != null ) {
+                this.portletContainer.shutdown();
+                this.portletContainer = null;
+            }
+            ContainerUtil.dispose(this.portletContainerEnvironment);
+            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;
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        if ( this.servletConfig != null ) {
+            this.initContainer();
+        }
+    }
+
+    /**
+     * Return the portlet container
+     */
+    public PortletContainer getPortletContainer() {
+        return this.portletContainer;        
+    }
+
+    /**
+     * Return the portlet container environment
+     */
+    public PortletContainerEnvironment getPortletContainerEnvironment() {
+        return this.portletContainerEnvironment;        
+    }
+
+    /**
+     * Initialize the container
+     */
+    public void initContainer() throws Exception {
+        this.portletContainer = new PortletContainerImpl();
+
+        if (!portletContainer.isInitialized()) {
+            this.getLogger().debug ("Initializing PortletContainer...");
+
+            final String uniqueContainerName = "cocoon-portal";
+
+            this.portletContainerEnvironment = new PortletContainerEnvironmentImpl();
+            ContainerUtil.enableLogging(this.portletContainerEnvironment, this.getLogger());
+            ContainerUtil.contextualize(this.portletContainerEnvironment, this.context);
+            ContainerUtil.service(this.portletContainerEnvironment, this.manager);
+            ContainerUtil.initialize(this.portletContainerEnvironment);
+
+            Properties properties = new Properties();
+
+            try {
+                portletContainer.init(uniqueContainerName, servletConfig, this.portletContainerEnvironment,
properties);
+            } catch (PortletContainerException exc) {
+                throw new ProcessingException("Initialization of the portlet container failed.",
exc);
+            }
+        } else {
+            this.getLogger().debug("PortletContainer already initialized.");
+        }
+
+        this.getLogger().debug("PortletContainer initialized.");
+        
+    }
+
+    /**
+     * @see Receiver
+     */
+    public void inform(PortletURLProviderImpl event, PortalService service) {
+        final Map objectModel = ContextHelper.getObjectModel(this.context);
+        final ServletRequestImpl req = new ServletRequestImpl((HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT),
event);
+        final HttpServletResponse res = new ServletResponseImpl((HttpServletResponse) objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT));
+        objectModel.put("portlet-response",  res);
+        objectModel.put("portlet-request", req);        
+
+        if ( event.isAction() ) {
+            // This means we can only have ONE portlet event per request!
+            objectModel.put("portlet-event", event);
+        } else {
+            DynamicInformationProvider dynProv;
+            InformationProviderService ips;
+            PortletActionProvider pap;
+
+            ips = (InformationProviderService)this.portletContainerEnvironment.getContainerService(InformationProviderService.class);
+            dynProv = ips.getDynamicProvider(req);
+            pap = dynProv.getPortletActionProvider(event.getPortletWindow());
+            final PortletMode mode = event.getPortletMode();
+            if ( mode != null ) {
+                pap.changePortletMode(mode);
+            }
+            final WindowState state = event.getWindowState();
+            if ( state != null ) {
+                pap.changePortletWindowState(state);
+            }
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.PortalManagerAspect#prepare(org.apache.cocoon.portal.PortalManagerAspectPrepareContext,
org.apache.cocoon.portal.PortalService)
+     */
+    public void prepare(PortalManagerAspectPrepareContext aspectContext,
+                        PortalService service)
+    throws ProcessingException {
+        // process the events
+        aspectContext.invokeNext();
+        
+        // if we aren't running in a servlet environment, just skip the JSR-168 part
+        if ( this.servletConfig == null ) {
+            return;
+        }
+        
+        // do we already have an environment?
+        // if not, create one
+        final Map objectModel = aspectContext.getObjectModel();
+
+        PortletURLProviderImpl event = (PortletURLProviderImpl) objectModel.get("portlet-event");
+        if ( event != null ) {
+            PortletWindow actionWindow = event.getPortletWindow();
+            try {
+                final ServletRequestImpl req = (ServletRequestImpl) objectModel.get("portlet-request");
+                final ServletResponseImpl res= (ServletResponseImpl)objectModel.get("portlet-response");
+                this.portletContainer.processPortletAction(actionWindow, req.getRequest(actionWindow),
res);
+            } catch (Exception ignore) {
+                this.getLogger().error("Error during processing of portlet action.", ignore);
+            }
+        } else if ( objectModel.get("portlet-response") == null ) {
+            final HttpServletResponse res = (HttpServletResponse) objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
+            objectModel.put("portlet-response",  new ServletResponseImpl(res));
+            final ServletRequestImpl req = new ServletRequestImpl((HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT),
null);
+            objectModel.put("portlet-request",  req);
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext,
org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
+     */
+    public void render(PortalManagerAspectRenderContext aspectContext,
+                       PortalService service,
+                       ContentHandler ch,
+                       Parameters parameters)
+    throws SAXException {
+        final Map objectModel = aspectContext.getObjectModel();
+
+        // don't generate a response, if we issued a redirect
+        if (objectModel.get("portlet-event") == null) {
+            aspectContext.invokeNext(ch, parameters);
         }
     }
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java?rev=226363&r1=226362&r2=226363&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java Fri
Jul 29 05:36:18 2005
@@ -28,7 +28,6 @@
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.avalon.framework.component.Component;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.cocoon.portal.PortalService;
@@ -56,7 +55,7 @@
  */
 public class PageLabelManager
     extends AbstractLogEnabled
-    implements ThreadSafe, Serviceable, Configurable, Contextualizable, Component {
+    implements ThreadSafe, Serviceable, Configurable, Contextualizable {
 
     public static final String ROLE = PageLabelManager.class.getName();
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerAspectChain.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerAspectChain.java?rev=226363&r1=226362&r2=226363&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerAspectChain.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerAspectChain.java
Fri Jul 29 05:36:18 2005
@@ -25,11 +25,12 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.cocoon.portal.PortalManagerAspect;
+import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
 
 /**
  * This chain holds all configured aspects for a portal manager.
  * @since 2.1.8
- * @version SVN $Id:$
+ * @version SVN $Id$
  */
 public final class PortalManagerAspectChain {
     
@@ -37,7 +38,8 @@
     
     protected List configs = new ArrayList(3);
     
-    public void configure(ServiceSelector     selector,
+    public void configure(ServiceSelector     aspectSelector,
+                          ServiceSelector     adapterSelector,
                           Configuration       conf,
                           PortalManagerAspect endAspect,
                           Parameters          endAspectParameters) 
@@ -46,19 +48,31 @@
             Configuration[] aspects = conf.getChildren("aspect");
             for(int i=0; i < aspects.length; i++) {
                 final Configuration current = aspects[i];
-                final String role = current.getAttribute("type");
-                if ( selector == null ) {
-                    throw new ConfigurationException("No selector for aspects defined.");
-                }
-                try {
-                    PortalManagerAspect pAspect = (PortalManagerAspect) selector.select(role);
-                    this.aspects.add(pAspect);               
-                    Parameters aspectConfiguration = Parameters.fromConfiguration(current);
-                    this.configs.add(aspectConfiguration);
-                    
-                } catch (ServiceException se) {
-                    throw new ConfigurationException("Unable to lookup aspect " + role, se);
+                final String role = current.getAttribute("type", null);
+                PortalManagerAspect pAspect;
+                if ( role != null ) {
+                    if ( aspectSelector == null ) {
+                        throw new ConfigurationException("No selector for aspects defined.");
+                    }
+                    try {
+                        pAspect = (PortalManagerAspect) aspectSelector.select(role);    
                   
+                    } catch (ServiceException se) {
+                        throw new ConfigurationException("Unable to lookup aspect " + role,
current, se);
+                    }
+                } else {
+                    final String adapterName = current.getAttribute("adapter", null);
+                    if ( adapterName == null ) {
+                        throw new ConfigurationException("Aspect configuration requires either
a type or an adapter attribute.", current);
+                    }
+                    try {
+                        pAspect = (PortalManagerAspect)adapterSelector.select(adapterName);
+                    } catch (ServiceException se) {
+                        throw new ConfigurationException("Unable to lookup coplet adapter
" + adapterName, current, se);
+                    }
                 }
+                this.aspects.add(pAspect);               
+                Parameters aspectConfiguration = Parameters.fromConfiguration(current);
+                this.configs.add(aspectConfiguration);
             }
         }
         this.aspects.add(endAspect);
@@ -73,10 +87,15 @@
         return this.configs.iterator();
     }
     
-    public void dispose(ServiceSelector selector) {
+    public void dispose(ServiceSelector aspectSelector, ServiceSelector adapterSelector)
{
         Iterator i = this.aspects.iterator();
         while (i.hasNext()) {
-            selector.release(i.next()); 
+            final Object component = i.next();
+            if ( component instanceof CopletAdapter ) {
+                adapterSelector.release(component);
+            } else {
+                aspectSelector.release(i.next());
+            }
         }
         this.aspects.clear();
         this.configs.clear();

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java?rev=226363&r1=226362&r2=226363&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java Fri
Jul 29 05:36:18 2005
@@ -36,6 +36,7 @@
 import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
 import org.apache.cocoon.portal.PortalManagerAspectRenderContext;
 import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
 import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.layout.renderer.Renderer;
@@ -62,6 +63,7 @@
     protected PortalManagerAspectChain chain;
 
     protected ServiceSelector aspectSelector;
+    protected ServiceSelector adapterSelector;
 
     /** The component context. */
     protected Context context;
@@ -76,6 +78,7 @@
         if ( this.manager.hasService(PortalManagerAspect.ROLE+"Selector") ) {
             this.aspectSelector = (ServiceSelector) this.manager.lookup( PortalManagerAspect.ROLE+"Selector");
         }
+        this.adapterSelector = (ServiceSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
     }
 
     /**
@@ -87,10 +90,12 @@
             this.portalService = null;
             this.manager = null;
             if ( this.chain != null) {
-                this.chain.dispose( this.aspectSelector );
+                this.chain.dispose( this.aspectSelector, this.adapterSelector );
             }
             this.manager.release( this.aspectSelector );
             this.aspectSelector = null;
+            this.manager.release( this.adapterSelector );
+            this.adapterSelector = null;
             this.manager = null;
         }
     }
@@ -124,7 +129,11 @@
      */
     public void configure(Configuration conf) throws ConfigurationException {
         this.chain = new PortalManagerAspectChain();
-        this.chain.configure(this.aspectSelector, conf.getChild("aspects"), this, new Parameters());
+        this.chain.configure(this.aspectSelector, 
+                             this.adapterSelector, 
+                             conf.getChild("aspects"), 
+                             this, 
+                             new Parameters());
     }
 
     /**

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/PortletWindowAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/PortletWindowAspect.java?rev=226363&r1=226362&r2=226363&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/PortletWindowAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/PortletWindowAspect.java
Fri Jul 29 05:36:18 2005
@@ -27,7 +27,7 @@
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
-import org.apache.cocoon.portal.impl.PortletPortalManagerAspect;
+import org.apache.cocoon.portal.coplet.adapter.impl.PortletAdapter;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.layout.impl.CopletLayout;
 import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
@@ -91,7 +91,7 @@
         try {
             // now get the portal manager
             ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
-            PortletPortalManagerAspect portalManager = (PortletPortalManagerAspect) servletConfig.getServletContext().getAttribute(PortletPortalManagerAspect.class.getName());
+            PortletAdapter portalManager = (PortletAdapter) servletConfig.getServletContext().getAttribute(PortletAdapter.class.getName());
             if ( portalManager != null ) {
                 this.environment = portalManager.getPortletContainerEnvironment();
             }



Mime
View raw message