Re: javax.management woes, again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hmm.  Looks like we need to start counting sequence numbers at 1
because MBeanServerDelegate.sendNotification sends delegate's own
sequence number if the supplied notification has a sequence number 
is <= 0.

Andrew.


2007-05-03  Andrew Haley  <aph@xxxxxxxxxx>

	* gnu/javax/management/Server.java (Server): Record the delegate.
	(registerMBean): Notify the delegate.
	(unregisterMBean): Likewise.
	(notify): New method.

Index: Server.java
===================================================================
--- Server.java	(revision 124185)
+++ Server.java	(working copy)
@@ -53,6 +53,7 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -75,6 +76,7 @@
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerDelegate;
+import javax.management.MBeanServerNotification;
 import javax.management.MBeanTrustPermission;
 import javax.management.NotCompliantMBeanException;
 import javax.management.Notification;
@@ -137,6 +139,15 @@
   private Map listeners;
 
   /**
+   * An MBean that emits notifications when an MBean is registered and
+   * unregistered with this server.
+   *
+   */
+  private final MBeanServerDelegate delegate;
+
+  static private final AtomicLong sequenceNumber = new AtomicLong(1);
+
+  /**
    * Initialise the delegate name.
    */
   static
@@ -171,6 +182,7 @@
   {
     this.defaultDomain = defaultDomain;
     this.outer = outer;
+    this.delegate = delegate;
     try
       {
 	registerMBean(delegate, DELEGATE_NAME);
@@ -1703,6 +1715,7 @@
     beans.put(name, new ServerInfo(obji, obj));
     if (register != null)
       register.postRegister(Boolean.TRUE);
+    notify(name, MBeanServerNotification.REGISTRATION_NOTIFICATION);
     return obji;
   }
 
@@ -2088,10 +2101,18 @@
 	  }
       }
     beans.remove(name);
+    notify(name, MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
     if (register != null)
       register.postDeregister();
   }
 
+   private void notify(ObjectName name, String type)
+   {
+      delegate.sendNotification
+	(new MBeanServerNotification
+	 (type, DELEGATE_NAME, sequenceNumber.getAndIncrement(), name));
+   }
+
   /**
    * Input stream which deserializes using the given classloader.
    */


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux