cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl DefaultEventManager.java
Date Wed, 10 Dec 2003 14:04:15 GMT
cziegeler    2003/12/10 06:04:15

  Modified:    src/blocks/portal/conf portal.xconf
               src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl
                        DefaultChangeAspectDataEventSubscriber.java
               src/blocks/portal/java/org/apache/cocoon/portal/event/impl
                        DefaultEventManager.java
  Log:
  Making the event manager configurable
  
  Revision  Changes    Path
  1.27      +8 -0      cocoon-2.1/src/blocks/portal/conf/portal.xconf
  
  Index: portal.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- portal.xconf	8 Dec 2003 15:56:26 -0000	1.26
  +++ portal.xconf	10 Dec 2003 14:04:15 -0000	1.27
  @@ -18,6 +18,14 @@
           <aspect type="full-screen-coplet"/>
           <aspect type="request-parameter"/>
       </event-aspects>
  +    <!-- add a new instance of each class as a subscriber: -->
  +    <subscriber-classes>
  +        <class name="org.apache.cocoon.portal.event.subscriber.impl.DefaultChangeAspectDataEventSubscriber"/>
  +    </subscriber-classes>
  +    <!-- add each component as a subscriber (the component should be thread safe): -->
  +    <subscriber-roles>
  +        <!-- <role name="AVALON-ROLE"/> -->
  +    </subscriber-roles>
    </component>
   
    <component class="org.apache.cocoon.portal.impl.PortalManagerImpl" logger="portal"
role="org.apache.cocoon.portal.PortalManager"/>
  
  
  
  1.5       +2 -3      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java
  
  Index: DefaultChangeAspectDataEventSubscriber.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultChangeAspectDataEventSubscriber.java	20 Oct 2003 13:36:42 -0000	1.4
  +++ DefaultChangeAspectDataEventSubscriber.java	10 Dec 2003 14:04:15 -0000	1.5
  @@ -50,7 +50,6 @@
   */
   package org.apache.cocoon.portal.event.subscriber.impl;
   
  -import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.cocoon.portal.aspect.Aspectalizable;
   import org.apache.cocoon.portal.event.Event;
   import org.apache.cocoon.portal.event.Filter;
  @@ -66,7 +65,7 @@
   public final class DefaultChangeAspectDataEventSubscriber 
       implements Subscriber {
   
  -    public DefaultChangeAspectDataEventSubscriber(ServiceManager manager) {
  +    public DefaultChangeAspectDataEventSubscriber() {
       }
   
       /* (non-Javadoc)
  
  
  
  1.11      +40 -3     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
  
  Index: DefaultEventManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultEventManager.java	20 Oct 2003 13:36:42 -0000	1.10
  +++ DefaultEventManager.java	10 Dec 2003 14:04:15 -0000	1.11
  @@ -60,6 +60,7 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +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;
  @@ -80,6 +81,7 @@
   import org.apache.cocoon.portal.event.Subscriber;
   import org.apache.cocoon.portal.event.aspect.EventAspect;
   import org.apache.cocoon.portal.event.subscriber.impl.DefaultChangeAspectDataEventSubscriber;
  +import org.apache.cocoon.util.ClassUtils;
   
   /**
    *
  @@ -159,8 +161,43 @@
               this.getLogger().debug("Initialising eventClass " + eventClass);
           }
   
  -        // FIXME (CZ,HIGH) : Make this configurable
  -        this.subscribe(new DefaultChangeAspectDataEventSubscriber(this.manager));
  +        // FIXME - the following configuration is not portal specific, it's global!
  +        // subscribe all configured roles
  +        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);
  +                    }
  +                }
  +            }
  +        }
  +        // subscribe all configured classes
  +        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);
  +                }
  +            }
  +        }
       }
   
       public void publish( final Event event ) {
  
  
  

Mime
View raw message