cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r325959 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: event/impl/DefaultEventManager.java tools/PortalToolManager.java
Date Mon, 17 Oct 2005 18:48:38 GMT
Author: cziegeler
Date: Mon Oct 17 11:48:12 2005
New Revision: 325959

URL: http://svn.apache.org/viewcvs?rev=325959&view=rev
Log:
Make components Startable

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java?rev=325959&r1=325958&r2=325959&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
Mon Oct 17 11:48:12 2005
@@ -23,21 +23,13 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.activity.Startable;
 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;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.portal.PortalService;
@@ -46,6 +38,7 @@
 import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.event.Receiver;
 import org.apache.cocoon.portal.event.aspect.EventAspect;
+import org.apache.cocoon.portal.impl.AbstractComponent;
 import org.apache.cocoon.util.ClassUtils;
 
 /**
@@ -64,17 +57,10 @@
  * @version $Id$
  */
 public class DefaultEventManager 
-    extends AbstractLogEnabled
+    extends AbstractComponent
     implements EventManager, 
-                Serviceable, 
-                Initializable, 
-                ThreadSafe,
-                Configurable,
-                Disposable,
-                Contextualizable {
-
-    /** The service manager. */
-    protected ServiceManager manager;
+               Configurable,
+               Startable {
 
     /** Our configuration. */
     protected Configuration configuration;
@@ -83,11 +69,6 @@
 
     protected ServiceSelector aspectSelector;
 
-    protected Context context;
-
-    /** The portal service. */
-    protected PortalService service;
-
     /** Introspected receiver classes. */
     protected Map receiverClasses = new HashMap();
 
@@ -95,14 +76,6 @@
     protected Map eventHierarchy = 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);
-    }
-
-    /**
      * Helper method to get the current object model 
      */
     protected Map getObjectModel() {
@@ -127,10 +100,24 @@
             }
             this.manager.release( this.aspectSelector );
             this.aspectSelector = null;
-            this.manager.release(this.service);
-            this.service = null;
-            this.manager = null;
         }
+        super.dispose();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Startable#start()
+     */
+    public void start() throws Exception {
+        // nothing to do
+        // but this implementation should be startable in order to
+        // instantiate this component on startup and not lazy!
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Startable#stop()
+     */
+    public void stop() throws Exception {
+        // nothing to do
     }
 
     /**
@@ -138,6 +125,7 @@
      */
     public void initialize()
     throws Exception {
+        super.initialize();
         // we create a tree of all events - we initialize this with the root class
         this.getHierarchyInfo(Event.class);
 
@@ -221,14 +209,6 @@
     }
 
     /**
-     * @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) {
@@ -250,7 +230,7 @@
                 getLogger().info("Informing receiver "+receiverInfo.receiver+" of event "+event.getClass());
             }
             try {
-                receiverInfo.method.invoke(receiverInfo.receiver, new Object[] {event, this.service});
+                receiverInfo.method.invoke(receiverInfo.receiver, new Object[] {event, this.portalService});
             } catch (Exception ignore) {
                 this.getLogger().warn("Exception during event dispatching on receiver " +
receiverInfo.receiver
                                      +" and event " + event, ignore);

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java?rev=325959&r1=325958&r2=325959&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java
Mon Oct 17 11:48:12 2005
@@ -25,7 +25,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Startable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
@@ -35,10 +35,9 @@
 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.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.impl.AbstractComponent;
 import org.apache.cocoon.portal.tools.helper.PortalObjects;
 import org.apache.cocoon.portal.tools.service.UserRightsService;
 import org.apache.excalibur.source.ModifiableSource;
@@ -52,14 +51,14 @@
  *
  * @version $Id$
  */
-public class PortalToolManager implements ThreadSafe, Parameterizable, Serviceable, Disposable
{
+public class PortalToolManager
+    extends AbstractComponent
+    implements Parameterizable, Startable {
 
 	public static final String ROLE = PortalToolManager.class.getName();
 
 	private Map tools = new HashMap();
 
-	private ServiceManager manager;
-
 	private List i18n = new ArrayList();
 
 	private String rootDir;
@@ -75,9 +74,6 @@
     /** The source resolver */
     protected SourceResolver resolver;
 
-    /** The portal service. */
-    protected PortalService service;
-
 	/**
 	 * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
 	 */
@@ -115,6 +111,23 @@
             this.resolver.release(fSource);
         }
 	}
+    /**
+     * @see org.apache.avalon.framework.activity.Startable#start()
+     */
+    public void start() throws Exception {
+        // nothing to do
+        // but this implementation should be startable in order to
+        // instantiate this component on startup to avoid source
+        // resolving problems
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Startable#stop()
+     */
+    public void stop() throws Exception {
+        // nothing to do
+    }
+
 
 	/**
 	 * Initializes the PortalToolManager. Reads the configuration of all plugins etc.
@@ -188,9 +201,8 @@
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
+        super.service(manager);
         this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
-        this.service = (PortalService)this.manager.lookup(PortalService.ROLE);
     }
 
     /**
@@ -239,7 +251,7 @@
     		key = "/" + key;
         }
         key = this.getClass().getName() + key;
-        return (String)this.service.getAttribute(key);
+        return (String)this.portalService.getAttribute(key);
     }
 
     /**
@@ -251,7 +263,7 @@
         if (!key.startsWith("/")) {
             key = "/" + key;
         }
-        this.service.setAttribute(key, value);
+        this.portalService.setAttribute(key, value);
     }
 
     /**
@@ -260,11 +272,9 @@
     public void dispose() {
         if ( this.manager != null ) {
             this.manager.release(this.resolver);
-            this.manager.release(this.service);
             this.resolver = null;
-            this.service = null;
-            this.manager = null;
         }
+        super.dispose();
     }
 
     public PortalObjects getPortalObjects() {



Mime
View raw message