summaryrefslogtreecommitdiff
path: root/gnu/javax
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2007-05-03 18:41:29 +0000
committerAndrew Haley <aph@redhat.com>2007-05-03 18:41:29 +0000
commita85ae80b7a397ab79c9f69cf492c00a4970d24cb (patch)
tree99c2ea4cb651ad920a3903873e6367d5a0e7f98a /gnu/javax
parent5412fc422cf496b6b6c80e15b2068b30a47b1f96 (diff)
downloadclasspath-a85ae80b7a397ab79c9f69cf492c00a4970d24cb.tar.gz
2007-05-03 Andrew Haley <aph@redhat.com>
* gnu/javax/management/Server.java (Server): Record the delegate. (registerMBean): Notify the delegate. (unregisterMBean): Likewise. (notify): New method.
Diffstat (limited to 'gnu/javax')
-rw-r--r--gnu/javax/management/Server.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/gnu/javax/management/Server.java b/gnu/javax/management/Server.java
index aa39c75ad..616854e95 100644
--- a/gnu/javax/management/Server.java
+++ b/gnu/javax/management/Server.java
@@ -53,6 +53,7 @@ import java.util.HashSet;
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.MBeanRegistration;
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 @@ public class Server
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 @@ public class Server
{
this.defaultDomain = defaultDomain;
this.outer = outer;
+ this.delegate = delegate;
try
{
registerMBean(delegate, DELEGATE_NAME);
@@ -1703,6 +1715,7 @@ public class Server
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 @@ public class Server
}
}
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.
*/