geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r109410 - /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
Date Thu, 02 Dec 2004 00:46:23 GMT
Author: dain
Date: Wed Dec  1 16:46:21 2004
New Revision: 109410

URL: http://svn.apache.org/viewcvs?view=rev&rev=109410
Log:
Removed DependencyManager use of MBeanServer

Modified:
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java?view=diff&rev=109410&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java&r1=109409&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java&r2=109410
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java
Wed Dec  1 16:46:21 2004
@@ -26,16 +26,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerNotification;
-import javax.management.Notification;
-import javax.management.NotificationFilterSupport;
-import javax.management.NotificationListener;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.kernel.jmx.JMXUtil;
-
 /**
  * DependencyManager is the record keeper of the dependencies in Geronimo.  The DependencyManager
  * does not enforce any dependencies, it is simply a place where components can register
their intent
@@ -47,13 +39,18 @@
  * The names parent and child have no other meaning are just a convience to make the code
readable.
  *
  * @version $Rev$ $Date$
- * @jmx:mbean
  */
-public class DependencyManager implements NotificationListener {
+public class DependencyManager {
+    /**
+     * The lifecycleMonitor informs us when gbeans go off line,
+     * so we can clean up the lingering dependencies.
+     */
+    private final LifecycleMonitor lifecycleMonitor;
+
     /**
-     * The mbean server we are registered with.
+     * Listenes for GBeans to unregister and removes all dependencies associated with the
dependency
      */
-    private MBeanServer mbeanServer;
+    private final LifecycleListener lifecycleListener = new DependecyManagerLifecycleListener();
 
     /**
      * A map from child names to a list of parents.
@@ -71,21 +68,14 @@
      */
     private final Map startHoldsMap = new HashMap();
 
-    public DependencyManager(MBeanServer mbeanServer) throws Exception {
-        assert mbeanServer != null;
-        this.mbeanServer = mbeanServer;
-        NotificationFilterSupport mbeanServerFilter = new NotificationFilterSupport();
-        mbeanServerFilter.enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
-        mbeanServer.addNotificationListener(JMXUtil.DELEGATE_NAME, this, mbeanServerFilter,
null);
+    public DependencyManager(LifecycleMonitor lifecycleMonitor) throws Exception {
+        assert lifecycleMonitor != null;
+        this.lifecycleMonitor = lifecycleMonitor;
+        lifecycleMonitor.addLifecycleListener(lifecycleListener, new ObjectName("*:*"));
     }
 
     public synchronized void close() {
-        try {
-            mbeanServer.removeNotificationListener(JMXUtil.DELEGATE_NAME, this);
-        } catch (JMException ignored) {
-            // no big deal... just good citizen clean up code
-        }
-        mbeanServer = null;
+        lifecycleMonitor.removeLifecycleListener(lifecycleListener);
         childToParentMap.clear();
         parentToChildMap.clear();
         startHoldsMap.clear();
@@ -275,16 +265,13 @@
         return null;
     }
 
-    // todo convert this over to a kernel life cycle listener.... if possible
-    public void handleNotification(Notification n, Object handback) {
-        String type = n.getType();
-        if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(type)) {
-            MBeanServerNotification notification = (MBeanServerNotification) n;
-            ObjectName source = notification.getMBeanName();
-            synchronized (this) {
-                removeAllDependencies(source);
-                removeAllStartHolds(source);
+    private class DependecyManagerLifecycleListener extends LifecycleAdapter {
+        public void unloaded(ObjectName objectName) {
+            synchronized (DependencyManager.this) {
+                removeAllDependencies(objectName);
+                removeAllStartHolds(objectName);
             }
+
         }
     }
 }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java?view=diff&rev=109410&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r1=109409&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r2=109410
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	Wed Dec
 1 16:46:21 2004
@@ -560,7 +560,7 @@
         mbServer = MBeanServerFactory.createMBeanServer(domainName);
         mbServer.registerMBean(this, KERNEL);
         lifecycleMonitor = new LifecycleMonitor(mbServer);
-        dependencyManager = new DependencyManager(mbServer);
+        dependencyManager = new DependencyManager(lifecycleMonitor);
         proxyManager = new ProxyManager(this);
 
         // set up the data for the new configuration manager instance

Mime
View raw message