cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r515620 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ cocoon-portal-impl/src/main/java/org/apache/cocoon/p...
Date Wed, 07 Mar 2007 15:59:02 GMT
Author: cziegeler
Date: Wed Mar  7 07:59:00 2007
New Revision: 515620

URL: http://svn.apache.org/viewvc?view=rev&rev=515620
Log:
Refactor aspect handling and simplified configuration: automatic configuration of system services


Removed:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/aspects/impl/PageLabelProfileManagerAspect.java
Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/PortalManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PageLabelLinkService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/RegistrationBeanPostProcessor.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java
Wed Mar  7 07:59:00 2007
@@ -24,6 +24,7 @@
 import org.apache.cocoon.portal.om.CopletType;
 import org.apache.cocoon.portal.om.Layout;
 import org.apache.cocoon.portal.om.LayoutInstance;
+import org.apache.cocoon.portal.services.aspects.AspectChain;
 
 /**
  * The profile manager provides access to the portal profile (or parts
@@ -89,4 +90,6 @@
      * Get a specific coplet type for the current user.
      */
     CopletType getCopletType(String id);
+
+    AspectChain getProfileManagerAspectChain();
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
Wed Mar  7 07:59:00 2007
@@ -33,6 +33,7 @@
 import org.apache.cocoon.portal.om.LayoutException;
 import org.apache.cocoon.portal.om.PortalUser;
 import org.apache.cocoon.portal.profile.ProfileManager;
+import org.apache.cocoon.portal.services.aspects.AspectChain;
 import org.apache.cocoon.portal.services.aspects.impl.support.ProfileManagerAspectContextImpl;
 import org.apache.cocoon.portal.services.aspects.support.AspectChainImpl;
 import org.apache.cocoon.portal.util.AbstractBean;
@@ -43,8 +44,8 @@
  *
  * @version $Id$
  */
-public abstract class AbstractProfileManager 
-    extends AbstractBean 
+public abstract class AbstractProfileManager
+    extends AbstractBean
     implements ProfileManager, Receiver, Ordered {
 
     /** The chain for the configured profile manager aspects. */
@@ -59,6 +60,13 @@
     }
 
     /**
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getProfileManagerAspectChain()
+     */
+    public AspectChain getProfileManagerAspectChain() {
+        return this.chain;
+    }
+
+    /**
      * Receives any user related event and invokes login, logout etc.
      * @see Receiver
      */
@@ -114,7 +122,7 @@
                         if ( cid.getCopletDefinition() != null ) {
                             // now invoke login on each instance
                             CopletAdapter adapter;
-                            adapter = this.portalService.getCopletAdapter(cid.getCopletDefinition().getCopletType().getCopletAdapterName());
                           
+                            adapter = this.portalService.getCopletAdapter(cid.getCopletDefinition().getCopletType().getCopletAdapterName());
                             adapter.login( cid );
                         }
                     }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/PortalManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/PortalManager.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/PortalManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/PortalManager.java
Wed Mar  7 07:59:00 2007
@@ -19,8 +19,7 @@
 import java.util.Properties;
 
 import org.apache.cocoon.portal.PortalException;
-import org.apache.cocoon.portal.services.aspects.RequestProcessorAspect;
-import org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect;
+import org.apache.cocoon.portal.services.aspects.AspectChain;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -66,6 +65,7 @@
                 Properties     properties)
     throws SAXException;
 
-    void register(ResponseProcessorAspect aspect);
-    void register(RequestProcessorAspect aspect);
+    AspectChain getResponseProcessorAspectChain();
+
+    AspectChain getRequestProcessorAspectChain();
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
Wed Mar  7 07:59:00 2007
@@ -117,28 +117,28 @@
 
     protected static long idCounter = System.currentTimeMillis();
 
-    /** 
+    /**
      * Configure a layout
      */
-    protected void configureLayout(Configuration layoutConf) 
+    protected void configureLayout(Configuration layoutConf)
     throws ConfigurationException {
         LayoutDescription desc = new LayoutDescription();
         final String type = layoutConf.getAttribute("type");
-   
+
         // unique test
         if ( this.layouts.get(type) != null) {
             throw new ConfigurationException("Layout type must be unique. Double definition
for " + type);
         }
         desc.setType(type);
-        desc.setClassName(layoutConf.getAttribute("class"));        
+        desc.setClassName(layoutConf.getAttribute("class"));
         desc.setCreateId(layoutConf.getAttributeAsBoolean("create-id", false));
         desc.setItemClassName(layoutConf.getAttribute("item-class", null));
         desc.setDefaultIsStatic(layoutConf.getAttributeAsBoolean("default-is-static", false));
 
         // the renderers
         final String defaultRenderer = layoutConf.getChild("renderers").getAttribute("default");
-        desc.setDefaultRendererName(defaultRenderer); 
-         
+        desc.setDefaultRendererName(defaultRenderer);
+
         final Configuration[] rendererConfs = layoutConf.getChild("renderers").getChildren("renderer");
         if ( rendererConfs != null ) {
             boolean found = false;
@@ -161,7 +161,7 @@
     /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
      */
-    public void configure(Configuration configuration) 
+    public void configure(Configuration configuration)
     throws ConfigurationException {
         final Configuration[] layoutsConf = configuration.getChild("layouts").getChildren("layout");
         for(int i=0; i < layoutsConf.length; i++ ) {
@@ -176,7 +176,7 @@
     /**
      * @see org.apache.cocoon.portal.services.LayoutFactory#newInstance(java.lang.String)
      */
-    public Layout newInstance(String layoutType) 
+    public Layout newInstance(String layoutType)
     throws LayoutException {
         return this.newInstance(layoutType, null);
     }
@@ -184,7 +184,7 @@
     /**
      * @see org.apache.cocoon.portal.services.LayoutFactory#newInstance(java.lang.String,
java.lang.String)
      */
-    public Layout newInstance(String layoutType, String id) 
+    public Layout newInstance(String layoutType, String id)
     throws LayoutException {
         LayoutDescription layoutDescription = (LayoutDescription)this.layouts.get( layoutType
);
 
@@ -216,6 +216,8 @@
     }
 
     /**
+     * Inform this bean about a remove layout event.
+     * @param event The remove layout event
      * @see Receiver
      */
     public void inform(RemoveLayoutEvent event) {

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java
Wed Mar  7 07:59:00 2007
@@ -25,6 +25,7 @@
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.portal.PortalException;
+import org.apache.cocoon.portal.PortalRuntimeException;
 import org.apache.cocoon.portal.layout.renderer.Renderer;
 import org.apache.cocoon.portal.om.CopletInstance;
 import org.apache.cocoon.portal.om.CopletInstanceFeatures;
@@ -33,6 +34,7 @@
 import org.apache.cocoon.portal.om.LayoutFeatures;
 import org.apache.cocoon.portal.profile.ProfileManager;
 import org.apache.cocoon.portal.services.PortalManager;
+import org.apache.cocoon.portal.services.aspects.AspectChain;
 import org.apache.cocoon.portal.services.aspects.RequestProcessorAspect;
 import org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext;
 import org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect;
@@ -61,12 +63,22 @@
     /** The aspect chain for additional response processing. */
     protected AspectChainImpl responseChain;
 
+    public DefaultPortalManager() {
+        this.setRequestAspectChain(new AspectChainImpl(RequestProcessorAspect.class));
+        this.setResponseAspectChain(new AspectChainImpl(ResponseProcessorAspect.class));
+    }
+
     /**
      * Set the request aspect chain.
      * @param a A chain.
      */
     public void setRequestAspectChain(AspectChainImpl a) {
         this.requestChain = a;
+        try {
+            this.requestChain.addAspect(this, null);
+        } catch (PortalException e) {
+            throw new PortalRuntimeException("Unable to add DefaultPortalManager to request
aspect chain.", e);
+        }
     }
 
     /**
@@ -75,6 +87,11 @@
      */
     public void setResponseAspectChain(AspectChainImpl a) {
         this.responseChain = a;
+        try {
+            this.responseChain.addAspect(this, null);
+        } catch (PortalException e) {
+            throw new PortalRuntimeException("Unable to add DefaultPortalManager to response
aspect chain.", e);
+        }
     }
 
     /**
@@ -98,34 +115,19 @@
 	}
 
     /**
-     * Initialize
-     * @throws PortalException
-     */
-    public void init()
-    throws PortalException {
-        if ( this.requestChain == null ) {
-            this.requestChain = new AspectChainImpl(RequestProcessorAspect.class);
-        }
-        this.requestChain.addAspect(this, null);
-        if ( this.responseChain == null ) {
-            this.responseChain = new AspectChainImpl(ResponseProcessorAspect.class);
-        }
-        this.responseChain.addAspect(this, null);
-    }
-
-    /**
      * @see org.apache.cocoon.portal.services.aspects.RequestProcessorAspect#process(org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext)
      */
     public void process(RequestProcessorAspectContext rpContext) {
-        // by defaut, we have nothing to do
+        // by defaut, we have nothing to do, except invoking the next
+        rpContext.invokeNext();
     }
 
     /**
      * @see org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect#render(org.apache.cocoon.portal.services.aspects.ResponseProcessorAspectContext,
org.xml.sax.ContentHandler, java.util.Properties)
      */
     public void render(ResponseProcessorAspectContext renderContext,
-                       ContentHandler                   ch,
-                       Properties                       properties)
+                       ContentHandler                 ch,
+                       Properties                     properties)
     throws SAXException {
         final ProfileManager profileManager = this.portalService.getProfileManager();
 
@@ -235,28 +237,16 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.services.PortalManager#register(org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect)
+     * @see org.apache.cocoon.portal.services.PortalManager#getRequestProcessorAspectChain()
      */
-    public void register(ResponseProcessorAspect aspect) {
-        try {
-            this.responseChain.addAspect(aspect, null, 0);
-        } catch (PortalException pe) {
-            final IllegalArgumentException e = new IllegalArgumentException("Unable to add
portal manager aspects.");
-            e.initCause(pe);
-            throw e;
-        }
+    public AspectChain getRequestProcessorAspectChain() {
+        return this.requestChain;
     }
 
     /**
-     * @see org.apache.cocoon.portal.services.PortalManager#register(org.apache.cocoon.portal.services.aspects.RequestProcessorAspect)
+     * @see org.apache.cocoon.portal.services.PortalManager#getResponseProcessorAspectChain()
      */
-    public void register(RequestProcessorAspect aspect) {
-        try {
-            this.responseChain.addAspect(aspect, null, 0);
-        } catch (PortalException pe) {
-            final IllegalArgumentException e = new IllegalArgumentException("Unable to add
portal manager aspects.");
-            e.initCause(pe);
-            throw e;
-        }
+    public AspectChain getResponseProcessorAspectChain() {
+        return this.responseChain;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java
Wed Mar  7 07:59:00 2007
@@ -33,6 +33,7 @@
 import org.apache.cocoon.portal.event.EventConverter;
 import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.services.LinkService;
+import org.apache.cocoon.portal.services.aspects.DynamicAspect;
 import org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext;
 import org.apache.cocoon.portal.util.AbstractBean;
 
@@ -45,7 +46,7 @@
  */
 public class DefaultLinkService
     extends AbstractBean
-    implements LinkService {
+    implements LinkService, DynamicAspect {
 
     /** Default port used for http. */
     protected int defaultPort = 80;

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PageLabelLinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PageLabelLinkService.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PageLabelLinkService.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PageLabelLinkService.java
Wed Mar  7 07:59:00 2007
@@ -16,18 +16,29 @@
  */
 package org.apache.cocoon.portal.services.impl.links;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.event.Event;
 import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.event.layout.ChangeTabEvent;
+import org.apache.cocoon.portal.om.CompositeLayout;
+import org.apache.cocoon.portal.om.Item;
+import org.apache.cocoon.portal.om.Layout;
+import org.apache.cocoon.portal.om.LayoutFeatures;
+import org.apache.cocoon.portal.om.NamedItem;
+import org.apache.cocoon.portal.services.aspects.ProfileManagerAspect;
+import org.apache.cocoon.portal.services.aspects.ProfileManagerAspectContext;
 import org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext;
-import org.apache.cocoon.portal.services.aspects.impl.PageLabelProfileManagerAspect;
 
 
 /**
@@ -36,10 +47,17 @@
  *
  * @version $Id$
  */
-public class PageLabelLinkService extends DefaultLinkService {
+public class PageLabelLinkService
+    extends DefaultLinkService
+    implements ProfileManagerAspect {
+
+    protected static final String PAGE_LABEL_MAP = PageLabelLinkService.class.getName() +
"/pageLabelMap";
+    protected static final String PAGE_LABEL_ATTR= PageLabelLinkService.class.getName() +
"/pageLabel";
 
     protected String pageLabelRequestParameter = "pageLabel";
 
+    protected boolean stickyTabs = false;
+
     public void setPageLabelRequestParameter(String pageLabelRequestParameter) {
         this.pageLabelRequestParameter = pageLabelRequestParameter;
     }
@@ -55,7 +73,7 @@
                 final Event current = (Event)i.next();
                 if ( current instanceof ChangeTabEvent ) {
                     final ChangeTabEvent tabEvent = (ChangeTabEvent)current;
-                    final String pageLabel = (String)tabEvent.getItem().getTemporaryAttribute("pageLabel");
+                    final String pageLabel = (String)tabEvent.getItem().getTemporaryAttribute(PAGE_LABEL_ATTR);
                     if ( pageLabel != null ) {
                         i.remove();
                         if ( parameterDescriptions == null ) {
@@ -73,7 +91,7 @@
      * @see org.apache.cocoon.portal.services.impl.links.DefaultLinkService#process(org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext)
      */
     public void process(RequestProcessorAspectContext context) {
-        final Map pageLabelMap = (Map)context.getPortalService().getUserService().getAttribute("pageLabelMap");
+        final Map pageLabelMap = (Map)context.getPortalService().getUserService().getAttribute(PAGE_LABEL_MAP);
         if ( pageLabelMap != null ) {
             final Request request = ObjectModelHelper.getRequest(context.getPortalService().getProcessInfoProvider().getObjectModel());
             final EventManager publisher = context.getPortalService().getEventManager();
@@ -86,7 +104,7 @@
                     if ( events != null ) {
                         final Iterator iter = events.iterator();
                         while ( iter.hasNext() ) {
-                            final PageLabelProfileManagerAspect.PageLabelEventInfo event
= (PageLabelProfileManagerAspect.PageLabelEventInfo)iter.next();
+                            final PageLabelEventInfo event = (PageLabelEventInfo)iter.next();
                             // TODO - check for change
                             publisher.send(event.createEvent(context.getPortalService()));
                         }
@@ -96,4 +114,100 @@
         }
         super.process(context);
     }
+
+    /**
+     * @see org.apache.cocoon.portal.services.aspects.ProfileManagerAspect#prepareCopletDefinitions(org.apache.cocoon.portal.services.aspects.ProfileManagerAspectContext,
java.util.Collection)
+     */
+    public void prepareCopletDefinitions(ProfileManagerAspectContext context, Collection
copletDefinitions) {
+        context.invokeNext(copletDefinitions);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.aspects.ProfileManagerAspect#prepareCopletInstances(org.apache.cocoon.portal.services.aspects.ProfileManagerAspectContext,
java.util.Collection)
+     */
+    public void prepareCopletInstances(ProfileManagerAspectContext context, Collection copletInstances)
{
+        context.invokeNext(copletInstances);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.aspects.ProfileManagerAspect#prepareCopletTypes(org.apache.cocoon.portal.services.aspects.ProfileManagerAspectContext,
java.util.Collection)
+     */
+    public void prepareCopletTypes(ProfileManagerAspectContext context, Collection copletTypes)
{
+        context.invokeNext(copletTypes);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.aspects.ProfileManagerAspect#prepareLayout(org.apache.cocoon.portal.services.aspects.ProfileManagerAspectContext,
org.apache.cocoon.portal.om.Layout)
+     */
+    public void prepareLayout(ProfileManagerAspectContext context, Layout rootLayout) {
+        if ( rootLayout instanceof CompositeLayout ) {
+            final Map pageLabelMap = new HashMap();
+            this.populate(context.getPortalService(), (CompositeLayout)rootLayout, pageLabelMap,
"", null);
+            context.getPortalService().getUserService().setAttribute(PAGE_LABEL_MAP, pageLabelMap);
+        }
+        context.invokeNext(rootLayout);
+    }
+
+    private List populate(PortalService service, CompositeLayout layout, Map map, String
name, List parentEvents) {
+        List lhList = null;
+        for (int j = 0; j < layout.getSize(); j++) {
+            final Item tab = layout.getItem(j);
+            final PageLabelEventInfo event = new PageLabelEventInfo(layout, tab);
+            final StringBuffer label = new StringBuffer(name);
+            if (label.length() > 0) {
+                label.append(".");
+            }
+            label.append((tab instanceof NamedItem) ? ((NamedItem) tab).getName()
+                                                    : Integer.toString(j));
+            try {
+                tab.setTemporaryAttribute(PAGE_LABEL_ATTR, URLEncoder.encode(label.toString(),
"utf-8"));
+            } catch (UnsupportedEncodingException e) {
+                // this can never happen
+            }
+
+            final List events = (parentEvents != null ? new ArrayList(parentEvents) : new
ArrayList());
+            events.add(event);
+
+            Layout child = tab.getLayout();
+            List allEvents = null;
+            if (child != null && child instanceof CompositeLayout) {
+                allEvents = populate(service, (CompositeLayout) child, map, label.toString(),
events);
+            }
+            if ( !this.stickyTabs ) {
+                // With non-sticky tabs the non-leaf nodes always display
+                // the left-most child tabs
+                if (lhList == null) {
+                    if (allEvents != null) {
+                        lhList = allEvents;
+                    } else {
+                        lhList = events;
+                    }
+                }
+                if (allEvents != null) {
+                    map.put(label.toString(), allEvents);
+                } else {
+                    map.put(label.toString(), events);
+                }
+            } else {
+                map.put(label.toString(), events);
+            }
+        }
+        return lhList;
+    }
+
+    public static final class PageLabelEventInfo {
+
+        protected final CompositeLayout layout;
+        protected final Item            item;
+
+        public PageLabelEventInfo(final CompositeLayout l, final Item i) {
+            this.layout = l;
+            this.item = i;
+        }
+
+        public ChangeTabEvent createEvent(PortalService service) {
+            return new ChangeTabEvent(LayoutFeatures.getLayoutInstance(service, this.layout,
true), this.item, false);
+        }
+    }
+
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/RegistrationBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/RegistrationBeanPostProcessor.java?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/RegistrationBeanPostProcessor.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/RegistrationBeanPostProcessor.java
Wed Mar  7 07:59:00 2007
@@ -16,13 +16,16 @@
  */
 package org.apache.cocoon.portal.spring;
 
+import org.apache.cocoon.portal.PortalException;
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.services.aspects.DynamicAspect;
+import org.apache.cocoon.portal.services.aspects.ProfileManagerAspect;
 import org.apache.cocoon.portal.services.aspects.RequestProcessorAspect;
 import org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.BeanInitializationException;
 import org.springframework.beans.factory.config.BeanPostProcessor;
 
 /**
@@ -47,11 +50,21 @@
      * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object,
java.lang.String)
      */
     public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
{
-        if ( bean instanceof DynamicAspect && bean instanceof ResponseProcessorAspect
) {
-            ((PortalService)this.beanFactory.getBean(PortalService.class.getName())).getPortalManager().register((ResponseProcessorAspect)bean);
-        }
-        if ( bean instanceof DynamicAspect && bean instanceof RequestProcessorAspect
) {
-            ((PortalService)this.beanFactory.getBean(PortalService.class.getName())).getPortalManager().register((RequestProcessorAspect)bean);
+        if ( bean instanceof DynamicAspect ) {
+            final PortalService portalService = (PortalService) this.beanFactory.getBean(PortalService.class.getName());
+            try {
+                if ( bean instanceof ResponseProcessorAspect ) {
+                    portalService.getPortalManager().getResponseProcessorAspectChain().addAspect(bean,
null, 0);
+                }
+                if ( bean instanceof RequestProcessorAspect ) {
+                    portalService.getPortalManager().getRequestProcessorAspectChain().addAspect(bean,
null, -1);
+                }
+                if ( bean instanceof ProfileManagerAspect ) {
+                    portalService.getProfileManager().getProfileManagerAspectChain().addAspect(bean,
null, -1);
+                }
+            } catch (PortalException pe) {
+                throw new BeanInitializationException("Unable to register dynamic aspect
of bean " + beanName, pe);
+            }
         }
         return bean;
     }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
Wed Mar  7 07:59:00 2007
@@ -100,15 +100,13 @@
     <bean name="org.apache.cocoon.portal.services.PortalManager"
           class="org.apache.cocoon.portal.services.impl.DefaultPortalManager"
           parent="org.apache.cocoon.portal.util.AbstractBean"
-          init-method="init" scope="singleton">
+          scope="singleton">
       <property name="requestAspectChain" ref="org.apache.cocoon.portal.services.PortalManager.requestAspects"/>
       <property name="responseAspectChain" ref="org.apache.cocoon.portal.services.PortalManager.responseAspects"/>
     </bean>
 
-    <!-- We register only the link service as a request processor. The aspect configuration
-         should be redefined in the portal config. -->
+    <!-- We register an empty aspects bean which should be redefined in the portal config.
-->
     <portal:request-processor-aspects id="org.apache.cocoon.portal.services.PortalManager.requestAspects">
-      <portal:aspect ref="org.apache.cocoon.portal.services.LinkService"/>
     </portal:request-processor-aspects>
 
     <!-- We register an empty aspects bean which should be redefined in the portal config.
-->
@@ -212,9 +210,6 @@
       | Profile Manager Aspects.
       |
       +-->
-    <bean name="org.apache.cocoon.portal.services.aspects.ProfileManagerAspect.page-labels"
-          class="org.apache.cocoon.portal.services.aspects.impl.PageLabelProfileManagerAspect"
-          parent="org.apache.cocoon.portal.util.AbstractBean" scope="singleton"/>
 
     <!-- We register an empty aspects bean which should be redefined in the portal config.
-->
     <portal:profile-manager-aspects id="org.apache.cocoon.portal.profile.ProfileManager.aspects"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml?view=diff&rev=515620&r1=515619&r2=515620
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
Wed Mar  7 07:59:00 2007
@@ -78,7 +78,6 @@
       |
       +-->
     <portal:request-processor-aspects id="org.apache.cocoon.portal.services.PortalManager.requestAspects">
-      <portal:aspect ref="org.apache.cocoon.portal.services.LinkService"/>
       <!--  The client should not cache the page. -->
       <portal:aspect type="no-client-caching"/>
       <!-- Use the action counter with great care. We recommend turning it off. -->
@@ -106,7 +105,6 @@
       |
       +-->
     <portal:profile-manager-aspects id="org.apache.cocoon.portal.profile.ProfileManager.aspects">
-      <portal:aspect type="page-labels"/>
       <!-- Add your aspects here -->
     </portal:profile-manager-aspects>
 </beans>



Mime
View raw message