cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r332300 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: pluto/ pluto/adapter/ wsrp/adapter/
Date Thu, 10 Nov 2005 14:45:03 GMT
Author: cziegeler
Date: Thu Nov 10 06:44:55 2005
New Revision: 332300

URL: http://svn.apache.org/viewcvs?rev=332300&view=rev
Log:
Fix handling of portlet sizing and correct init order for portlet and wsrp env

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/DynamicInformationProviderImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/InformationProviderServiceImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletActionProviderImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletWindowAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/DynamicInformationProviderImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/DynamicInformationProviderImpl.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/DynamicInformationProviderImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/DynamicInformationProviderImpl.java
Thu Nov 10 06:44:55 2005
@@ -22,6 +22,7 @@
 import javax.portlet.WindowState;
 
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.pluto.om.PortletEntityImpl;
 import org.apache.pluto.om.window.PortletWindow;
@@ -36,21 +37,32 @@
  * @version $Id$
  */
 public class DynamicInformationProviderImpl 
-implements DynamicInformationProvider {
+    implements DynamicInformationProvider {
 
-    /** Service manager */
+    /** Service manager. */
     protected final ServiceManager manager;
 
-    /** The portal context provider */
+    /** The portal context provider. */
     protected final PortalContextProviderImpl provider;
 
+    /** The portal service. */
+    protected final PortalService portalService;
+
+    static protected final HashSet responseMimeTypes = new HashSet();
+
+    static {
+        responseMimeTypes.add("text/html");        
+    }
+
     /**
      * Constructor
      */
     public DynamicInformationProviderImpl(ServiceManager manager,
-                                          PortalContextProviderImpl provider) {
+                                          PortalContextProviderImpl provider,
+                                          PortalService service) {
         this.manager = manager;
         this.provider = provider;
+        this.portalService = service;
     }
 
     /**
@@ -71,7 +83,7 @@
      * @see org.apache.pluto.services.information.DynamicInformationProvider#getPortletActionProvider(org.apache.pluto.om.window.PortletWindow)
      */
     public PortletActionProvider getPortletActionProvider(PortletWindow portletWindow) {
-        return new PortletActionProviderImpl(portletWindow);
+        return new PortletActionProviderImpl(portletWindow, this.portalService);
     }
 
     /**
@@ -86,12 +98,6 @@
         return pm;
     }
 
-    public PortletMode getPreviousPortletMode(PortletWindow portletWindow) {
-        final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData();
-        PortletMode pm = (PortletMode) cid.getTemporaryAttribute("previous-portlet-mode");
-        return pm;
-    }
-
     /**
      * @see org.apache.pluto.services.information.DynamicInformationProvider#getWindowState(org.apache.pluto.om.window.PortletWindow)
      */
@@ -104,23 +110,11 @@
         return ws;
     }
 
-    public WindowState getPreviousWindowState(PortletWindow portletWindow) {
-        final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData();
-        WindowState ws = (WindowState) cid.getTemporaryAttribute("previous-window-state");
       
-        return ws;
-    }
-
     /**
      * @see org.apache.pluto.services.information.DynamicInformationProvider#getResponseContentType()
      */
     public String getResponseContentType() {
         return "text/html";
-    }
-
-    static protected final HashSet responseMimeTypes = new HashSet();
-
-    static {
-        responseMimeTypes.add("text/html");        
     }
 
     /**

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/InformationProviderServiceImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/InformationProviderServiceImpl.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/InformationProviderServiceImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/InformationProviderServiceImpl.java
Thu Nov 10 06:44:55 2005
@@ -17,13 +17,8 @@
 
 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.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.portal.impl.AbstractComponent;
 import org.apache.cocoon.portal.pluto.om.PortletDefinitionRegistry;
 import org.apache.pluto.services.PortletContainerEnvironment;
 import org.apache.pluto.services.information.DynamicInformationProvider;
@@ -35,11 +30,10 @@
  *
  * @version $Id$
  */
-public class InformationProviderServiceImpl 
-implements InformationProviderService, PortletContainerEnabled, Serviceable, Contextualizable
{
-
-    /** The service manager */
-    protected ServiceManager manager;
+public class InformationProviderServiceImpl
+    extends AbstractComponent
+    implements InformationProviderService,
+               PortletContainerEnabled {
 
     /** The portlet container environment */
     protected PortletContainerEnvironmentImpl portletContainerEnvironment;
@@ -50,9 +44,6 @@
     /** The portal context provider (thread safe) */
     protected PortalContextProviderImpl provider;
 
-    /** The component context */
-    protected Context context;
-
     final static protected String dynamicProviderRole= InformationProviderServiceImpl.class.getName();
 
     /**
@@ -81,25 +72,12 @@
 
         if (dynProvider == null) {
             dynProvider = new DynamicInformationProviderImpl(this.manager,
-                                                          this.getPortalContextProvider());
+                                                             this.getPortalContextProvider(),
+                                                             this.portalService);
             request.setAttribute(dynamicProviderRole, dynProvider);
         }
 
         return dynProvider;
-    }
-
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException {
-        this.context = context;
-    }
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
     }
 
     /**

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletActionProviderImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletActionProviderImpl.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletActionProviderImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletActionProviderImpl.java
Thu Nov 10 06:44:55 2005
@@ -18,7 +18,10 @@
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
 
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.event.Event;
+import org.apache.cocoon.portal.event.coplet.CopletInstanceSizingEvent;
 import org.apache.cocoon.portal.pluto.om.PortletEntityImpl;
 import org.apache.pluto.om.window.PortletWindow;
 import org.apache.pluto.services.information.PortletActionProvider;
@@ -30,15 +33,22 @@
  */
 public class PortletActionProviderImpl implements PortletActionProvider {
 
-    /** The target */
-    protected PortletWindow portletWindow;
+    /** The target. */
+    protected final PortletWindow portletWindow;
 
-    public PortletActionProviderImpl(PortletWindow portletWindow) {
+    /** The portal service. */
+    protected final PortalService portalService;
+
+    /**
+     * Constructor.
+     */
+    public PortletActionProviderImpl(PortletWindow portletWindow, PortalService service)
{
         this.portletWindow = portletWindow;
+        this.portalService = service;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.pluto.services.information.PortletActionProvider#changePortletMode(PortletWindow,
PortletMode)
+    /**
+     * @see org.apache.pluto.services.information.PortletActionProvider#changePortletMode(javax.portlet.PortletMode)
      */
     public void changePortletMode(PortletMode mode) {
         if ( mode != null ) {
@@ -46,16 +56,13 @@
             PortletMode pm = (PortletMode) cid.getTemporaryAttribute("portlet-mode");
             if ( (pm == null && !mode.equals(PortletMode.VIEW)) 
                 || (pm != null && !pm.equals(mode)) ) {
-                if ( pm != null ) {
-                    cid.setTemporaryAttribute("previous-portlet-mode", pm);
-                }
                 cid.setTemporaryAttribute("portlet-mode", mode);
             }
         }
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.pluto.services.information.PortletActionProvider#changePortletWindowState(PortletWindow,
WindowState)
+    /**
+     * @see org.apache.pluto.services.information.PortletActionProvider#changePortletWindowState(javax.portlet.WindowState)
      */
     public void changePortletWindowState(WindowState state) {
         if ( state != null ) {
@@ -63,12 +70,16 @@
             WindowState ws = (WindowState) cid.getTemporaryAttribute("window-state");
             if ( (ws == null && !state.equals(WindowState.NORMAL))
                 || (ws != null && !ws.equals(state)) ) {
-                if ( ws != null ) {
-                    cid.setTemporaryAttribute("previous-window-state", ws);
-                }
                 cid.setTemporaryAttribute("window-state", state);
+                int size = CopletInstanceData.SIZE_NORMAL;
+                if ( state.equals(WindowState.MAXIMIZED) ) {
+                    size = CopletInstanceData.SIZE_MAXIMIZED;
+                } else if ( state.equals(WindowState.MINIMIZED) ) {
+                    size = CopletInstanceData.SIZE_MINIMIZED;
+                }
+                final Event e = new CopletInstanceSizingEvent(cid, size);
+                this.portalService.getComponentManager().getEventManager().send(e);
             }
         }
     }
-
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
Thu Nov 10 06:44:55 2005
@@ -34,7 +34,6 @@
 import org.apache.cocoon.portal.event.CopletInstanceEvent;
 import org.apache.cocoon.portal.event.Event;
 import org.apache.cocoon.portal.event.ConvertableEvent;
-import org.apache.cocoon.portal.event.coplet.CopletInstanceSizingEvent;
 import org.apache.cocoon.portal.layout.impl.CopletLayout;
 import org.apache.cocoon.portal.pluto.om.PortletEntityImpl;
 import org.apache.cocoon.portal.pluto.om.PortletWindowImpl;
@@ -229,15 +228,6 @@
                 WindowState oldState = (WindowState)cid.getTemporaryAttribute("window-state");

                 if ( oldState == null ) {
                     oldState = WindowState.NORMAL;
-                }
-                if ( this.state != null && !this.state.equals(oldState) ) {
-                    if ( oldState.equals(WindowState.MAXIMIZED) ) {
-                        sizingEvent = new CopletInstanceSizingEvent( null, CopletInstanceData.SIZE_FULLSCREEN
);                    
-                    } else {
-                        if ( this.state.equals(WindowState.MAXIMIZED) ) {
-                            sizingEvent = new CopletInstanceSizingEvent( cid, CopletInstanceData.SIZE_FULLSCREEN
);                                            
-                        }
-                    }
                 }
             }
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
Thu Nov 10 06:44:55 2005
@@ -25,15 +25,10 @@
 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;
@@ -43,7 +38,6 @@
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter;
-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;
@@ -81,11 +75,8 @@
  */
 public class PortletAdapter 
     extends AbstractCopletAdapter
-    implements Contextualizable, Initializable, PortalManagerAspect, Receiver, Disposable
{
+    implements PortalManagerAspect, Receiver {
 	
-    /** The avalon context. */
-    protected Context context;
-    
     /** The servlet configuration for pluto. */
     protected ServletConfig servletConfig;
 
@@ -99,14 +90,9 @@
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
     public void contextualize(Context context) throws ContextException {
-        this.context = context;
+        super.contextualize(context);
         try {
-            // 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
@@ -114,8 +100,8 @@
             this.getLogger().warn("The JSR-168 support is disabled as the servlet context
is not available.", ignore);
         }
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.cocoon.portal.coplet.adapter.CopletAdapter#login(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void login(CopletInstanceData coplet) {
@@ -125,12 +111,12 @@
             return;
         }
         PortletDefinitionRegistry registry = (PortletDefinitionRegistry) portletContainerEnvironment.getContainerService(PortletDefinitionRegistry.class);
-        
+
         final String portletEntityId = (String) getConfiguration(coplet, "portlet");   
-        
+
         PortletApplicationEntity pae = registry.getPortletApplicationEntityList().get(ObjectIDImpl.createFromString("cocoon"));
         PortletEntity portletEntity = ((PortletEntityListImpl)pae.getPortletEntityList()).add(pae,
portletEntityId, coplet, registry);
-        
+
         if ( portletEntity.getPortletDefinition() != null ) {
             // create the window
             PortletWindow portletWindow = new PortletWindowImpl(portletEntityId);       
        
@@ -139,7 +125,7 @@
             PortletWindowList windowList = portletEntity.getPortletWindowList();        
             ((PortletWindowListCtrl)windowList).add(portletWindow);    
             coplet.setTemporaryAttribute("window", portletWindow);
-            
+
             // load the portlet
             final Map objectModel = ContextHelper.getObjectModel(this.context);
             ServletRequestImpl  req = (ServletRequestImpl) objectModel.get("portlet-request");
@@ -223,42 +209,16 @@
         if ( window != null ) {
             coplet.removeTemporaryAttribute("window");
             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();
@@ -269,16 +229,14 @@
         } catch (Throwable t) {
             this.getLogger().error("Destruction failed!", t);
         }
-        if ( this.servletConfig != null ) {
-            this.servletConfig.getServletContext().removeAttribute(PortletAdapter.class.getName());
-            this.servletConfig = null;
-        }
+        super.dispose();
     }
 
     /**
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
     public void initialize() throws Exception {
+        super.initialize();
         if ( this.servletConfig != null ) {
             this.initContainer();
         }
@@ -327,7 +285,6 @@
         }
 
         this.getLogger().debug("PortletContainer initialized.");
-        
     }
 
     /**
@@ -374,12 +331,12 @@
     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();
@@ -421,5 +378,4 @@
             aspectContext.invokeNext(ch, parameters);
         }
     }
-
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletWindowAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletWindowAspect.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletWindowAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletWindowAspect.java
Thu Nov 10 06:44:55 2005
@@ -17,12 +17,10 @@
 
 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.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
@@ -32,7 +30,6 @@
 import org.apache.cocoon.portal.layout.renderer.aspect.impl.AbstractAspect;
 import org.apache.cocoon.portal.pluto.PortletURLProviderImpl;
 import org.apache.cocoon.portal.pluto.om.PortletWindowImpl;
-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;
@@ -75,28 +72,33 @@
  * @version $Id$
  */
 public final class PortletWindowAspect 
-    extends AbstractAspect {
+    extends AbstractAspect
+    implements Parameterizable {
 
-    /** The environment */
+    /** The environment. */
     protected PortletContainerEnvironment environment;
 
+    /** The name of the configured portlet adapter. */
+    protected String adapterName = "portlet";
+
     /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
      */
-    public void contextualize(Context context) throws ContextException {
-        super.contextualize(context);
-        try {
-            // now get the portal manager
-            ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
-            PortletAdapter portalManager = (PortletAdapter) servletConfig.getServletContext().getAttribute(PortletAdapter.class.getName());
-            if ( portalManager != null ) {
-                this.environment = portalManager.getPortletContainerEnvironment();
-            }
-        } catch (ContextException ignore) {
-            // we ignore the context exception
-            // this avoids startup errors if the portal is configured for the CLI
-            // environment
-            this.getLogger().warn("The JSR-168 support is disabled as the servlet context
is not available.", ignore);
+    public void parameterize(Parameters params) throws ParameterException {
+        this.adapterName = params.getParameter("adapter-name", this.adapterName);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.impl.AbstractComponent#initialize()
+     */
+    public void initialize() throws Exception {
+        super.initialize();
+        PortletAdapter adapter = (PortletAdapter)this.portalService.getComponentManager().getCopletAdapter(this.adapterName);
+        if ( adapter != null ) {
+            this.environment = adapter.getPortletContainerEnvironment();
+        }
+        if ( this.environment == null ) {
+            this.getLogger().warn("The JSR-168 support is disabled as the servlet context
is not available.");            
         }
     }
 
@@ -156,14 +158,14 @@
                     PortletURLProviderImpl url = (PortletURLProviderImpl)dip.getPortletURLProvider(window);
                     url.clearParameters();
                     url.setWindowState(WindowState.NORMAL);
-                    XMLUtils.createElement(contenthandler, "maximize-uri", url.toString());
+                    XMLUtils.createElement(contenthandler, "normal-uri", url.toString());
                 }
 
                 if ( !ws.equals(WindowState.MAXIMIZED)) {
                     PortletURLProviderImpl url = (PortletURLProviderImpl)dip.getPortletURLProvider(window);
                     url.clearParameters();
                     url.setWindowState(WindowState.MAXIMIZED);
-                    XMLUtils.createElement(contenthandler, "fullscreen-uri", url.toString());
+                    XMLUtils.createElement(contenthandler, "maximize-uri", url.toString());
                 }
 
                 // portlet modes

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java
Thu Nov 10 06:44:55 2005
@@ -32,21 +32,17 @@
 import oasis.names.tc.wsrp.v1.types.SessionContext;
 import oasis.names.tc.wsrp.v1.types.UpdateResponse;
 
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 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.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Session;
@@ -59,7 +55,6 @@
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter;
 import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.event.Receiver;
 import org.apache.cocoon.portal.event.coplet.CopletInstanceSizingEvent;
 import org.apache.cocoon.portal.layout.Layout;
@@ -117,11 +112,7 @@
  */
 public class WSRPAdapter 
     extends AbstractCopletAdapter
-    implements Contextualizable,
-               PortalManagerAspect,
-               Serviceable,
-               Initializable,
-               Disposable,
+    implements PortalManagerAspect,
                Parameterizable,
                Receiver {
 
@@ -155,9 +146,6 @@
     /** Name of the service. */
     public static final String consumerAgent = "Apache Cocoon Portal." + org.apache.cocoon.Constants.VERSION;
     
-    /** The avalon context. */
-    protected Context context;
-    
     /** The consumer environment implementation. */
     protected ConsumerEnvironmentImpl consumerEnvironment;
     
@@ -167,12 +155,6 @@
     /** The servlet configuration. */
     protected ServletConfig servletConfig;
 
-    /** The service locator. */
-    protected ServiceManager manager;
-
-    /** The portal service. */
-    protected PortalService service;
-
     /** The user context provider. */
     protected UserContextProvider userContextProvider;
 
@@ -192,13 +174,9 @@
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
     public void contextualize(Context context) throws ContextException {
-        this.context = context;
+        super.contextualize(context);
         try {
             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(WSRPAdapter.class.getName(),
this);
         } catch (ContextException ignore) {
             // we ignore the context exception
             // this avoids startup errors if the portal is configured for the CLI
@@ -211,15 +189,7 @@
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-        EventManager eventManager = null;
-        try {
-            eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-            eventManager.subscribe(this);
-        } finally {
-            this.manager.release(eventManager);
-        }
-        this.service = (PortalService)this.manager.lookup(PortalService.ROLE);
+        super.service(manager);
         this.userContextProvider = (UserContextProvider)this.manager.lookup(UserContextProvider.ROLE);
     }
 
@@ -237,11 +207,12 @@
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
     public void initialize() throws Exception {
+        super.initialize();
         LogManager.setLogManager(new WSRPLogManager(new WSRPLogger(this.getLogger())));
         this.consumerEnvironment = new ConsumerEnvironmentImpl();
-        this.consumerEnvironment.init(this.service, 
+        this.consumerEnvironment.init(this.portalService, 
                                       this);
-        consumerEnvironment.setConsumerAgent(consumerAgent);
+        this.consumerEnvironment.setConsumerAgent(consumerAgent);
     }
 
     /**
@@ -250,38 +221,26 @@
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
     public void dispose() {
-        
-        consumerEnvironment.getPortletRegistry().removeAllPortlets();
-        
-        Iterator producers = consumerEnvironment.getProducerRegistry().getAllProducers();
-        Producer producer;
-        while (producers.hasNext()) {
-            producer = (Producer) producers.next();
-            try {
-                producer.deregister();    
-            } catch (WSRPException e) {
-                this.getLogger().error("deregister() producer: " + producer.getName());
+        if ( this.consumerEnvironment != null ) {
+            this.consumerEnvironment.getPortletRegistry().removeAllPortlets();
+
+            Iterator producers = this.consumerEnvironment.getProducerRegistry().getAllProducers();
+            Producer producer;
+            while (producers.hasNext()) {
+                producer = (Producer) producers.next();
+                try {
+                    producer.deregister();    
+                } catch (WSRPException e) {
+                    this.getLogger().error("deregister() producer: " + producer.getName());
+                }
             }
+            this.consumerEnvironment.getProducerRegistry().removeAllProducers();
+
+            this.consumerEnvironment.getUserRegistry().removeAllUsers();
         }
-        consumerEnvironment.getProducerRegistry().removeAllProducers();
-        
-        consumerEnvironment.getUserRegistry().removeAllUsers();
-        
         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.release(this.service);
             this.manager.release(this.userContextProvider);
-            this.service = null;
             this.userContextProvider = null;
-            this.manager = null;
         }
         try {
             ContainerUtil.dispose(this.consumerEnvironment);
@@ -289,11 +248,7 @@
         } catch (Throwable t) {
             this.getLogger().error("Destruction failed!", t);
         }
-        
-        if ( this.servletConfig != null ) {
-            this.servletConfig.getServletContext().removeAttribute(WSRPAdapter.class.getName());
-            this.servletConfig = null;
-        }
+        super.dispose();
     }
 
     /**
@@ -323,7 +278,7 @@
         }
 
         // get the wsrp user and store it as an attribute on the instance
-        final String currentUserID = this.service.getComponentManager().getProfileManager().getUser().getUserName();
      
+        final String currentUserID = this.portalService.getComponentManager().getProfileManager().getUser().getUserName();
      
         User user = this.consumerEnvironment.getUserRegistry().getUser(currentUserID);
         if ( user == null ) {
             // create a new user
@@ -356,7 +311,7 @@
             }
         }
         coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY, portletKey);
-        final Session session = ObjectModelHelper.getRequest(this.service.getObjectModel()).getSession();
+        final Session session = ObjectModelHelper.getRequest(this.portalService.getObjectModel()).getSession();
         final String portletInstanceKey = this.getPortletInstanceKey(portletKey, coplet,
session.getId());
         coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY, portletInstanceKey);
 
@@ -898,7 +853,7 @@
             ((RequiresWSRPAdapter)component).setWSRPAdapter(this);
         }
         if (component instanceof RequiresPortalService) {
-            ((RequiresPortalService)component).setPortalService(this.service);
+            ((RequiresPortalService)component).setPortalService(this.portalService);
         }
         ContainerUtil.contextualize(component, context);
         ContainerUtil.service(component, manager);
@@ -906,5 +861,4 @@
 
         return component;
     }
-
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java?rev=332300&r1=332299&r2=332300&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
Thu Nov 10 06:44:55 2005
@@ -18,12 +18,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.servlet.ServletConfig;
-
 import oasis.names.tc.wsrp.v1.types.LocalizedString;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.portal.PortalService;
@@ -34,7 +30,6 @@
 import org.apache.cocoon.portal.layout.renderer.aspect.impl.AbstractAspect;
 import org.apache.cocoon.portal.wsrp.consumer.ConsumerEnvironmentImpl;
 import org.apache.cocoon.portal.wsrp.consumer.SimplePortletWindowSession;
-import org.apache.cocoon.servlet.CocoonServlet;
 import org.apache.cocoon.xml.XMLUtils;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.wsrp4j.consumer.PortletKey;
@@ -50,7 +45,7 @@
 
 /**
  * This aspect draws a portlet window for a wsrp portlet.
- * 
+ *
  * <h2>Example XML:</h2>
  * <pre>
  *   &lt;window&gt;
@@ -64,12 +59,12 @@
  *     &lt;!-- output of following renderers --&gt;
  *   &lt;/window&gt;
  * </pre>
- * 
+ *
  * <h2>Applicable to:</h2>
  * <ul>
  *  <li>{@link org.apache.cocoon.portal.layout.impl.CopletLayout}</li>
  * </ul>
- * 
+ *
  * <h2>Parameters</h2>
  * <table><tbody>
  * <tr><th>root-tag</th><td>Should a root tag surrounding the following
output
@@ -77,7 +72,7 @@
  * <tr><th>tag-name</th><td>Name of the root tag if requested.
  *  </td><td></td><td>String</td><td><code>"window"</code></td></tr>
  * </tbody></table>
- * 
+ *
  * @version $Id$
  */
 public final class WSRPPortletWindowAspect 
@@ -89,24 +84,26 @@
     /** The wsrp adapter. */
     protected WSRPAdapter adapter;
 
+    /** The name of the configured wsrp adapter. */
+    protected String adapterName = "wsrp";
+
     /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
      */
-    public void contextualize(Context context) throws ContextException {
-        super.contextualize(context);
-        try {
-            // now get the wsrp adapter
-            ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
-            this.adapter = (WSRPAdapter)servletConfig.getServletContext().getAttribute(WSRPAdapter.class.getName());
-            if ( this.adapter != null ) {
-                this.environment = this.adapter.getConsumerEnvironment();
-            }
-        } catch (ContextException ignore) {
-            // we ignore the context exception
-            // this avoids startup errors if the portal is configured for the CLI
-            // environment
-            this.getLogger().warn("The wsrp support is disabled as the servlet context is
not available.", ignore);
+    public void parameterize(Parameters params) throws ParameterException {
+        this.adapterName = params.getParameter("adapter-name", this.adapterName);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.impl.AbstractComponent#initialize()
+     */
+    public void initialize() throws Exception {
+        super.initialize();
+        this.adapter = (WSRPAdapter)this.portalService.getComponentManager().getCopletAdapter(this.adapterName);
+        if ( this.adapter != null ) {
+            this.environment = this.adapter.getConsumerEnvironment();
         }
+        this.getLogger().warn("The wsrp support is disabled as the servlet context is not
available.");
     }
 
     /**
@@ -175,7 +172,7 @@
                         p.put(Constants.WINDOW_STATE, WindowStates._normal);
 
                         final String link = urlGenerator.getRenderURL(p);
-                        XMLUtils.createElement(contenthandler, "maximize-uri", link);
+                        XMLUtils.createElement(contenthandler, "normal-uri", link);
                     } 
                     if ( !ws.equals(WindowStates._maximized)
                           && ArrayUtils.contains(supportedWindowStates, WindowStates._maximized))
{
@@ -184,7 +181,7 @@
                         p.put(Constants.WINDOW_STATE, WindowStates._maximized);
 
                         final String link = urlGenerator.getRenderURL(p);               
        
-                        XMLUtils.createElement(contenthandler, "fullscreen-uri", link);
+                        XMLUtils.createElement(contenthandler, "maximize-uri", link);
                     }
 
                     String[] supportedModes = (String[])copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_MODES);



Mime
View raw message