cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r219049 [2/2] - in /cocoon/branches/BRANCH_2_1_X/src/blocks/portal: conf/ java/org/apache/cocoon/portal/ java/org/apache/cocoon/portal/acting/ java/org/apache/cocoon/portal/coplet/adapter/impl/ java/org/apache/cocoon/portal/coplets/basket/ ...
Date Thu, 14 Jul 2005 15:11:55 GMT
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
Thu Jul 14 08:11:52 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Copyright 1999-2002,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.
@@ -15,7 +15,9 @@
  */
 package org.apache.cocoon.portal.event.impl;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -42,10 +44,12 @@
 import org.apache.cocoon.portal.event.EventConverter;
 import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.event.Publisher;
+import org.apache.cocoon.portal.event.Receiver;
 import org.apache.cocoon.portal.event.Register;
 import org.apache.cocoon.portal.event.Subscriber;
 import org.apache.cocoon.portal.event.aspect.EventAspect;
 import org.apache.cocoon.util.ClassUtils;
+import org.apache.cocoon.util.Deprecation;
 
 /**
  * This is the default implementation of the event manager.
@@ -53,7 +57,7 @@
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * 
- * @version CVS $Id: DefaultEventManager.java,v 1.14 2004/03/05 13:02:12 bdelacretaz Exp
$
+ * @version CVS $Id$
  */
 public class DefaultEventManager 
     extends AbstractLogEnabled
@@ -68,7 +72,11 @@
                     
     private final String rootEventType = Event.class.getName();
     private Class eventClass;
+    /** The list of all subscribers. */
     private List subscribers = new ArrayList();
+    /** The list of all receivers */
+    private Map receivers = new HashMap();
+
     private ServiceManager manager;
     private Configuration configuration;
     
@@ -77,12 +85,19 @@
     protected ServiceSelector aspectSelector;
 
     protected Context context;
-    
-    /* (non-Javadoc)
+
+    /** The portal service */
+    protected PortalService service;
+
+    /** Introspected receiver classes */
+    protected Map receiverClasses = new HashMap();
+
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
+        this.service = (PortalService)manager.lookup(PortalService.ROLE);
     }
 
     /* (non-Javadoc)
@@ -124,6 +139,8 @@
             }
             this.manager.release( this.aspectSelector );
             this.aspectSelector = null;
+            this.manager.release(this.service);
+            this.service = null;
             this.manager = null;
         }
     }
@@ -143,18 +160,17 @@
         Configuration roles = this.configuration.getChild("subscriber-roles", false);
         if ( roles != null ) {
             Configuration[] rolesConf = roles.getChildren("role");
-            if ( rolesConf != null ) {
-                for(int i=0; i<rolesConf.length;i++) {
-                    final Configuration current = rolesConf[i];
-                    final String name = current.getAttribute("name");
-                    
-                    Subscriber subscriber = null;
-                    try {
-                        subscriber = (Subscriber) this.manager.lookup(name);
-                        this.subscribe(subscriber);
-                    } finally {
-                        this.manager.release(subscriber);
-                    }
+            for(int i=0; i<rolesConf.length;i++) {
+                final Configuration current = rolesConf[i];
+                final String name = current.getAttribute("name");
+                
+                Subscriber subscriber = null;
+                try {
+                    subscriber = (Subscriber) this.manager.lookup(name);
+                    Deprecation.logger.warn("Subscriber is deprecated. Please convert the
following component to a Receiver: " + subscriber.getClass().getName());
+                    this.subscribe(subscriber);
+                } finally {
+                    this.manager.release(subscriber);
                 }
             }
         }
@@ -162,39 +178,60 @@
         Configuration classes = this.configuration.getChild("subscriber-classes", false);
         if ( classes != null ) {
             Configuration[] classesConf = classes.getChildren("class");
-            if ( classesConf != null ) {
-                for(int i=0; i<classesConf.length;i++) {
-                    final Configuration current = classesConf[i];
-                    final String name = current.getAttribute("name");
-                    
-                    Subscriber subscriber = (Subscriber) ClassUtils.newInstance(name);
-                    ContainerUtil.enableLogging(subscriber, this.getLogger());
-                    ContainerUtil.service(subscriber, this.manager );
-                    ContainerUtil.initialize(subscriber);
-                    this.subscribe(subscriber);
+            for(int i=0; i<classesConf.length;i++) {
+                final Configuration current = classesConf[i];
+                final String name = current.getAttribute("name");
+                
+                Deprecation.logger.warn("Subscriber is deprecated. Please convert the following
component to a Receiver: " + name);
+                Subscriber subscriber = (Subscriber) ClassUtils.newInstance(name);
+                ContainerUtil.enableLogging(subscriber, this.getLogger());
+                ContainerUtil.contextualize(subscriber, this.context);
+                ContainerUtil.service(subscriber, this.manager );
+                ContainerUtil.initialize(subscriber);
+                this.subscribe(subscriber);
+            }
+        }
+        // subscribe all configured receiver roles
+        roles = this.configuration.getChild("receiver-roles", false);
+        if ( roles != null ) {
+            Configuration[] rolesConf = roles.getChildren("role");
+            for(int i=0; i<rolesConf.length;i++) {
+                final Configuration current = rolesConf[i];
+                final String name = current.getAttribute("name");
+                
+                Receiver receiver = null;
+                try {
+                    receiver = (Receiver) this.manager.lookup(name);
+                    this.subscribe(receiver);
+                } finally {
+                    this.manager.release(receiver);
                 }
             }
         }
+        // subscribe all configured receiver classes
+        classes = this.configuration.getChild("receiver-classes", false);
+        if ( classes != null ) {
+            Configuration[] classesConf = classes.getChildren("class");
+            for(int i=0; i<classesConf.length;i++) {
+                final Configuration current = classesConf[i];
+                final String name = current.getAttribute("name");
+                
+                Receiver receiver = (Receiver)ClassUtils.newInstance(name);
+                ContainerUtil.enableLogging(receiver, this.getLogger());
+                ContainerUtil.contextualize(receiver, this.context);
+                ContainerUtil.service(receiver, this.manager );
+                ContainerUtil.initialize(receiver);
+                this.subscribe(receiver);
+            }
+        }
+
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.event.Publisher#publish(org.apache.cocoon.portal.event.Event)
      */
     public void publish( final Event event ) {
-        
-        if ( getLogger().isDebugEnabled() ) {
-            getLogger().debug("Publishing event " + event.getClass());
-        } 
-        for ( Iterator e = subscribers.iterator(); e.hasNext(); ){
-            Subscriber subscriber = (Subscriber)e.next();
-            if (subscriber.getEventType().isAssignableFrom(event.getClass())
-            && (subscriber.getFilter() == null || subscriber.getFilter().filter(event)))
{
-                if ( getLogger().isDebugEnabled() ) {
-                    getLogger().info("Informing subscriber "+subscriber+" of event "+event.getClass());
-                }
-                subscriber.inform(event);
-            }
-        }
+        this.send(event);        
     }
     
     /* (non-Javadoc)
@@ -284,12 +321,117 @@
 
     }
 
-    /* (non-Javadoc)
+    /**
      * @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.cocoon.portal.event.EventManager#send(org.apache.cocoon.portal.event.Event)
+     */
+    public void send(Event event) {
+        if ( getLogger().isDebugEnabled() ) {
+            getLogger().debug("Publishing event " + event.getClass());
+        } 
+        for ( Iterator e = subscribers.iterator(); e.hasNext(); ){
+            Subscriber subscriber = (Subscriber)e.next();
+            if (subscriber.getEventType().isAssignableFrom(event.getClass())
+            && (subscriber.getFilter() == null || subscriber.getFilter().filter(event)))
{
+                if ( getLogger().isDebugEnabled() ) {
+                    getLogger().info("Informing subscriber "+subscriber+" of event "+event.getClass());
+                }
+                subscriber.inform(event);
+            }
+        }
+        for (Iterator re = receivers.entrySet().iterator(); re.hasNext(); ) {
+            final Map.Entry current = (Map.Entry)re.next();
+            final Receiver receiver = (Receiver)current.getKey();
+            final List methodInfos = (List)current.getValue();
+            boolean found = false;
+            final Iterator ci = methodInfos.iterator();
+            while ( !found && ci.hasNext() ) {
+                final MethodInfo info = (MethodInfo)ci.next();
+                if ( info.eventClass.isAssignableFrom(event.getClass()) ) {
+                    if ( getLogger().isDebugEnabled() ) {
+                        getLogger().info("Informing receiver "+receiver+" of event "+event.getClass());
+                    }
+                    try {
+                        info.method.invoke(receiver, new Object[] {event, this.service});
+                    } catch (Exception ignore) {
+                        this.getLogger().warn("Exception during event dispatching on receiver
" + receiver
+                                             +" and event " + event, ignore);
+                    }
+                    found = true;
+                }
+            }
+        }
+    }
+
+    protected static final class MethodInfo {
+        
+        public Class eventClass;
+        public Method method;
+    }
+
+    protected synchronized List introspect(Class receiverClass) {
+        List result = (List)this.receiverClasses.get(receiverClass.getName());
+        if ( result == null ) {
+            result = new ArrayList();
+            Method[] methods = receiverClass.getMethods();
+            for(int i=0; i<methods.length; i++ ) {
+                final Method current = methods[i];
+                if ( current.getName().equals("inform") ) {
+                    final Class[] params = current.getParameterTypes();
+                    if ( params.length == 2 
+                         && params[1].getName().equals(PortalService.class.getName()))
{
+                        if ( eventClass.isAssignableFrom( params[0] ) ) {
+                            MethodInfo info = new MethodInfo();
+                            info.eventClass = params[0];
+                            info.method = current;
+                            result.add(info);
+                        }
+                    }
+                }
+            }
+            if ( result.size() == 0 ) {
+                result = null;
+            }
+        }
+        return result;
+    }
+ 
+    /**
+     * @see org.apache.cocoon.portal.event.EventManager#subscribe(org.apache.cocoon.portal.event.Receiver)
+     */
+    public void subscribe(Receiver receiver) {
+        List infos = this.introspect(receiver.getClass());
+        if ( infos == null ) {
+            throw new RuntimeException("Invalid event receiver type: " + receiver);
+        }
+
+        // Add to list but prevent duplicate subscriptions
+        List eventClassesForReceiver = (List)this.receivers.get(receiver);
+        if ( eventClassesForReceiver == null ) {
+            this.receivers.put(receiver, infos);
+        }
+        if ( getLogger().isDebugEnabled() ) {
+            for(int i=0; i<infos.size();i++) {
+                getLogger().debug( "Receiver " + receiver + " subscribed for event: " + ((MethodInfo)infos.get(i)).eventClass.getName()
);
+            }
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.event.EventManager#unsubscribe(org.apache.cocoon.portal.event.Receiver)
+     */
+    public void unsubscribe(Receiver receiver) {
+        if ( getLogger().isDebugEnabled() ) {
+            getLogger().debug( "Receiver " + receiver + " unsubscribed.");
+        }
+        this.receivers.remove(receiver);
     }
 
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/FullScreenCopletEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/FullScreenCopletEvent.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/FullScreenCopletEvent.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/FullScreenCopletEvent.java
Thu Jul 14 08:11:52 2005
@@ -26,17 +26,17 @@
  *
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
- * 
+ *
  * @version CVS $Id$
  */
-public class FullScreenCopletEvent 
-    extends CopletStatusEvent 
+public class FullScreenCopletEvent
+    extends CopletStatusEvent
     implements RequestEvent, ConvertableEvent {
 
     public static final String REQUEST_PARAMETER_NAME = "cocoon-portal-fs";
-    
+
     protected Layout layout;
-    
+
     public FullScreenCopletEvent(CopletInstanceData data, Layout layout) {
         this.coplet = data;
         this.layout = layout;
@@ -67,7 +67,7 @@
     public String getRequestParameterName() {
         return REQUEST_PARAMETER_NAME;
     }
-    
+
     public Layout getLayout() {
         return this.layout;
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaulCopletDataEventSubscriber.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaulCopletDataEventSubscriber.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaulCopletDataEventSubscriber.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaulCopletDataEventSubscriber.java
Thu Jul 14 08:11:52 2005
@@ -18,18 +18,13 @@
 import java.util.Iterator;
 import java.util.List;
 
-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.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletData;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.event.CopletDataEvent;
 import org.apache.cocoon.portal.event.Event;
 import org.apache.cocoon.portal.event.EventManager;
-import org.apache.cocoon.portal.event.Filter;
-import org.apache.cocoon.portal.event.Publisher;
-import org.apache.cocoon.portal.event.Subscriber;
+import org.apache.cocoon.portal.event.Receiver;
 import org.apache.cocoon.portal.event.impl.ChangeCopletsJXPathEvent;
 import org.apache.cocoon.portal.event.impl.CopletJXPathEvent;
 import org.apache.cocoon.portal.profile.ProfileManager;
@@ -41,11 +36,8 @@
  * @version CVS $Id$
  */
 public final class DefaulCopletDataEventSubscriber 
-implements Subscriber, Serviceable {
+implements Receiver {
 
-    /** The service manager */
-    protected ServiceManager manager;
-    
     /**
      * Constructor
      */
@@ -53,67 +45,26 @@
         // nothing to do 
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getEventType()
-     */
-    public Class getEventType() {
-        return CopletDataEvent.class;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getFilter()
-     */
-    public Filter getFilter() {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#inform(org.apache.cocoon.portal.event.Event)
+    /**
+     * @see Receiver
      */
-    public void inform(Event e) {
-        CopletData data = (CopletData) ((CopletDataEvent)e).getTarget();
-        PortalService service = null;
+    public void inform(CopletDataEvent e, PortalService service) {
+        CopletData data = (CopletData)e.getTarget();
         List instances = null;
-        try {
-            service = (PortalService) this.manager.lookup(PortalService.ROLE);
-            ProfileManager profileManager = service.getComponentManager().getProfileManager();
-            instances = profileManager.getCopletInstanceData(data);
-        } catch (Exception ignore) {
-            // ignore exception
-        } finally {
-            this.manager.release(service);
-        }
-        if ( instances != null ) {
-            Publisher publisher = null;
-            EventManager eventManager = null;
-            try {
-                eventManager = (EventManager) this.manager.lookup(EventManager.ROLE);
-                publisher = eventManager.getPublisher();
-            } catch (Exception ignore) {
-                // ignore exception
-            } finally {
-                this.manager.release(eventManager);
-            }
 
-            if ( publisher != null ) {
-                if ( e instanceof ChangeCopletsJXPathEvent ) {
-                    final String path = ((ChangeCopletsJXPathEvent)e).getPath();
-                    final Object value = ((ChangeCopletsJXPathEvent)e).getValue();
+        ProfileManager profileManager = service.getComponentManager().getProfileManager();
+        instances = profileManager.getCopletInstanceData(data);
+
+        if ( instances != null && e instanceof ChangeCopletsJXPathEvent ) {
+            EventManager eventManager = service.getComponentManager().getEventManager();
+            final String path = ((ChangeCopletsJXPathEvent)e).getPath();
+            final Object value = ((ChangeCopletsJXPathEvent)e).getValue();
                     
-                    Iterator i = instances.iterator();
-                    while ( i.hasNext() ) {
-                        CopletInstanceData current = (CopletInstanceData) i.next();
-                        Event event = new CopletJXPathEvent(current, path, value);
-                        publisher.publish(event);
-                    }
-                }
+            Iterator i = instances.iterator();
+            while ( i.hasNext() ) {
+                CopletInstanceData current = (CopletInstanceData) i.next();
+                Event event = new CopletJXPathEvent(current, path, value);
+                eventManager.send(event);
             }
         }
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java
Thu Jul 14 08:11:52 2005
@@ -15,10 +15,9 @@
  */
 package org.apache.cocoon.portal.event.subscriber.impl;
 
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.aspect.Aspectalizable;
-import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.event.Filter;
-import org.apache.cocoon.portal.event.Subscriber;
+import org.apache.cocoon.portal.event.Receiver;
 import org.apache.cocoon.portal.event.impl.ChangeAspectDataEvent;
 
 /**
@@ -28,31 +27,16 @@
  * @version CVS $Id$
  */
 public final class DefaultChangeAspectDataEventSubscriber 
-    implements Subscriber {
+    implements Receiver {
 
     public DefaultChangeAspectDataEventSubscriber() {
         // nothing to do 
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getEventType()
+    /**
+     * @see Receiver
      */
-    public Class getEventType() {
-        return ChangeAspectDataEvent.class;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getFilter()
-     */
-    public Filter getFilter() {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#inform(org.apache.cocoon.portal.event.Event)
-     */
-    public void inform(Event e) {
-        final ChangeAspectDataEvent event = (ChangeAspectDataEvent)e;
+    public void inform(ChangeAspectDataEvent event, PortalService service) {
         final Aspectalizable target = event.getAspectalizable();
         target.setAspectData(event.getAspectName(), event.getData());
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultJXPathEventSubscriber.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultJXPathEventSubscriber.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultJXPathEventSubscriber.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultJXPathEventSubscriber.java
Thu Jul 14 08:11:52 2005
@@ -15,44 +15,28 @@
  */
 package org.apache.cocoon.portal.event.subscriber.impl;
 
-import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.event.Filter;
-import org.apache.cocoon.portal.event.Subscriber;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.event.Receiver;
 import org.apache.cocoon.portal.event.impl.JXPathEvent;
 import org.apache.commons.jxpath.JXPathContext;
 
 /**
- * This subscriber processes JXPath events
+ * This subscriber processes JXPath events.
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
- * 
+ *
  * @version CVS $Id$
  */
 public final class DefaultJXPathEventSubscriber 
-    implements Subscriber {
+    implements Receiver {
 
     public DefaultJXPathEventSubscriber() {
         // nothing to do         
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getEventType()
+    /**
+     * @see Receiver
      */
-    public Class getEventType() {
-        return JXPathEvent.class;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getFilter()
-     */
-    public Filter getFilter() {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#inform(org.apache.cocoon.portal.event.Event)
-     */
-    public void inform(Event e) {
-        final JXPathEvent event = (JXPathEvent)e;
+    public void inform(JXPathEvent event, PortalService service) {
         final Object target = event.getTarget();
         if ( target != null ) {
             final JXPathContext jxpathContext = JXPathContext.newContext(target);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
Thu Jul 14 08:11:52 2005
@@ -17,7 +17,6 @@
 
 import java.util.Map;
 
-import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
@@ -46,8 +45,7 @@
  * @version CVS $Id: AbstractCopletTransformer.java 30941 2004-07-29 19:56:58Z vgritsenko
$
  */
 public abstract class AbstractCopletGenerator 
-extends ServiceableGenerator
-implements Disposable {
+extends ServiceableGenerator {
 
     /**
      * Parameter name.

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortletPortalManagerAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortletPortalManagerAspect.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortletPortalManagerAspect.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortletPortalManagerAspect.java
Thu Jul 14 08:11:52 2005
@@ -43,10 +43,8 @@
 import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
 import org.apache.cocoon.portal.PortalManagerAspectRenderContext;
 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.Filter;
-import org.apache.cocoon.portal.event.Subscriber;
+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.servlet.ServletRequestImpl;
@@ -67,7 +65,7 @@
  * This aspect provides the JSR-168 support by initializing Pluto.
  * The aspect can be configured at the portal manager.
  *
- * @version SVN $Id:$
+ * @version SVN $Id$
  */
 public class PortletPortalManagerAspect
 	extends AbstractLogEnabled
@@ -76,7 +74,7 @@
                Serviceable,
                Initializable,
                Disposable,
-               Subscriber {
+               Receiver {
 
     public static final ThreadLocal copletInstanceData = new InheritableThreadLocal();
 
@@ -122,7 +120,7 @@
         EventManager eventManager = null;
         try {
             eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-            eventManager.getRegister().subscribe(this);
+            eventManager.subscribe(this);
         } finally {
             this.manager.release(eventManager);
         }
@@ -136,7 +134,7 @@
             EventManager eventManager = null;
             try {
                 eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-                eventManager.getRegister().unsubscribe(this);
+                eventManager.unsubscribe(this);
             } catch (Exception ignore) {
                 // let's ignore it
             } finally {
@@ -216,30 +214,15 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.event.Subscriber#getEventType()
+     * @see Receiver
      */
-    public Class getEventType() {
-        return PortletURLProviderImpl.class;
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.event.Subscriber#getFilter()
-     */
-    public Filter getFilter() {
-        return null;
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.event.Subscriber#inform(org.apache.cocoon.portal.event.Event)
-     */
-    public void inform(Event e) {
-        PortletURLProviderImpl event = (PortletURLProviderImpl)e;
+    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);
@@ -247,7 +230,7 @@
             DynamicInformationProvider dynProv;
             InformationProviderService ips;
             PortletActionProvider pap;
-            
+
             ips = (InformationProviderService)this.portletContainerEnvironment.getContainerService(InformationProviderService.class);
             dynProv = ips.getDynamicProvider(req);
             pap = dynProv.getPortletActionProvider(event.getPortletWindow());
@@ -319,6 +302,7 @@
             aspectContext.invokeNext(ch, parameters);
         }
     }
+
 
 }
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
Thu Jul 14 08:11:52 2005
@@ -79,7 +79,7 @@
     String getItemClassName();
     
     /**
-     * @param itemClassName The item class name to set.
+     * @param value The item class name to set.
      */
     void setItemClassName(String value);
     

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java
Thu Jul 14 08:11:52 2005
@@ -120,7 +120,7 @@
     }
     
     /**
-     * @param itemClassName The item class name to set.
+     * @param value The item class name to set.
      */
     public void setItemClassName(String value) {
         this.itemClassName = value;

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
Thu Jul 14 08:11:52 2005
@@ -45,11 +45,9 @@
 import org.apache.cocoon.portal.coplet.CopletFactory;
 import org.apache.cocoon.portal.event.Event;
 import org.apache.cocoon.portal.event.EventManager;
-import org.apache.cocoon.portal.event.Filter;
 import org.apache.cocoon.portal.event.LayoutEvent;
-import org.apache.cocoon.portal.event.Subscriber;
+import org.apache.cocoon.portal.event.Receiver;
 import org.apache.cocoon.portal.event.impl.FullScreenCopletEvent;
-import org.apache.cocoon.portal.event.impl.LayoutRemoveEvent;
 import org.apache.cocoon.portal.layout.CompositeLayout;
 import org.apache.cocoon.portal.layout.Item;
 import org.apache.cocoon.portal.layout.Layout;
@@ -134,7 +132,7 @@
                  Disposable, 
                  Serviceable,
                  Initializable,
-                 Subscriber {
+                 Receiver {
 
     protected Map layouts = new HashMap();
     
@@ -362,7 +360,7 @@
             EventManager eventManager = null;
             try { 
                 eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-                eventManager.getRegister().unsubscribe( this );
+                eventManager.unsubscribe( this );
             } catch (Exception ignore) {
                 // ignore
             } finally {
@@ -382,39 +380,21 @@
         EventManager eventManager = null;
         try { 
             eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-            eventManager.getRegister().subscribe( this );
+            eventManager.subscribe( this );
         } finally {
             this.manager.release( eventManager );
         }
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getFilter()
-     */
-    public Filter getFilter() {
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getEventType()
-     */
-    public Class getEventType() {
-        return LayoutEvent.class;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#inform(org.apache.cocoon.portal.event.Event)
+    /**
+     * @see Receiver
      */
-    public void inform(Event e) {
-        // event dispatching
-        if ( e instanceof LayoutRemoveEvent ) {
-            LayoutRemoveEvent event = (LayoutRemoveEvent)e;
-            Layout layout = (Layout)event.getTarget();
-            try {
-                this.remove( layout );
-            } catch (ProcessingException pe) {
-                throw new CascadingRuntimeException("Exception during removal.", pe);
-            }
+    public void inform(LayoutEvent event, PortalService service) {
+        Layout layout = (Layout)event.getTarget();
+        try {
+            this.remove( layout );
+        } catch (ProcessingException pe) {
+            throw new CascadingRuntimeException("Exception during removal.", pe);
         }
     }
 
@@ -447,7 +427,7 @@
                     if ( layout.equals(service.getEntryLayout(null)) ) {
                         Event event = new FullScreenCopletEvent(((CopletLayout)layout).getCopletInstanceData(),
null);
                         eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-                        eventManager.getPublisher().publish(event);
+                        eventManager.send(event);
                         service.getComponentManager().getLinkService().addEventToLink(event);
                     }
                     CopletFactory factory = service.getComponentManager().getCopletFactory();

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractActionAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractActionAspect.java?rev=219049&r1=219048&r2=219049&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractActionAspect.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractActionAspect.java
Thu Jul 14 08:11:52 2005
@@ -18,8 +18,7 @@
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
 import org.apache.cocoon.portal.event.EventManager;
-import org.apache.cocoon.portal.event.Filter;
-import org.apache.cocoon.portal.event.Subscriber;
+import org.apache.cocoon.portal.event.Receiver;
 
 /**
  * This aspect creates an event and subscribes to it as well
@@ -30,14 +29,7 @@
  */
 public abstract class AbstractActionAspect
     extends AbstractAspect
-    implements Subscriber, Disposable, Initializable {
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Subscriber#getFilter()
-     */
-    public Filter getFilter() {
-        return null;
-    }
+    implements Receiver, Disposable, Initializable {
 
     /* (non-Javadoc)
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
@@ -47,7 +39,7 @@
             EventManager eventManager = null;
             try { 
                 eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-                eventManager.getRegister().unsubscribe( this );
+                eventManager.unsubscribe( this );
             } catch (Exception ignore) {
                 // ignore exceptions
             } finally {
@@ -65,7 +57,7 @@
         EventManager eventManager = null;
         try { 
             eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
-            eventManager.getRegister().subscribe( this );
+            eventManager.subscribe( this );
         } finally {
             this.manager.release( eventManager );
         }



Mime
View raw message