jdk/src/share/classes/javax/management/MBeanServerNotification.java
changeset 4156 acaa49a2768a
parent 1693 f99cde90680f
child 5506 202f599c92aa
--- a/jdk/src/share/classes/javax/management/MBeanServerNotification.java	Wed Oct 21 16:28:57 2009 +0200
+++ b/jdk/src/share/classes/javax/management/MBeanServerNotification.java	Wed Oct 21 17:33:18 2009 +0200
@@ -64,13 +64,13 @@
  *     mbeanServer.addNotificationListener(
  *             MBeanServerDelegate.DELEGATE_NAME, printListener, null, null);
  * </pre>
+ *
  * <p id="group">
  * An MBean which is not an {@link MBeanServerDelegate} may also emit
- * MBeanServerNotifications. In particular, a custom subclass of the
- * {@link javax.management.namespace.JMXDomain JMXDomain} MBean or a custom
- * subclass of the {@link javax.management.namespace.JMXNamespace JMXNamespace}
- * MBean may emit an MBeanServerNotification for a group of MBeans.<br>
- * An MBeanServerNotification emitted to denote the registration or
+ * MBeanServerNotifications. In particular, there is a convention for
+ * MBeans to emit an MBeanServerNotification for a group of MBeans.</p>
+ *
+ * <p>An MBeanServerNotification emitted to denote the registration or
  * unregistration of a group of MBeans has the following characteristics:
  * <ul><li>Its {@linkplain Notification#getType() notification type} is
  *     {@code "JMX.mbean.registered.group"} or
@@ -92,58 +92,6 @@
  * declare them in their {@link MBeanInfo#getNotifications()
  * MBeanNotificationInfo}.
  * </p>
- * <P>
- * To receive a group MBeanServerNotification, you need to register a listener
- * with the MBean that emits it. For instance, assuming that the {@link
- * javax.management.namespace.JMXNamespace JMXNamespace} MBean handling
- * namespace {@code "foo"} has declared that it emits such a notification,
- * you will need to register your notification listener with that MBean, which
- * will be named {@link
- * javax.management.namespace.JMXNamespaces#getNamespaceObjectName(java.lang.String)
- * foo//:type=JMXNamespace}.
- * </p>
- * <p>The following code prints a message every time a group of MBean is
- * registered or unregistered in the namespace {@code "foo"}, assumimg its
- * {@link javax.management.namespace.JMXNamespace handler} supports
- * group MBeanServerNotifications:</p>
- *
- * <pre>
- * private static final NotificationListener printListener = new NotificationListener() {
- *     public void handleNotification(Notification n, Object handback) {
- *         if (!(n instanceof MBeanServerNotification)) {
- *             System.out.println("Ignored notification of class " + n.getClass().getName());
- *             return;
- *         }
- *         MBeanServerNotification mbsn = (MBeanServerNotification) n;
- *         String what;
- *         ObjectName[] names = null;
- *         if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
- *             what = "MBean registered";
- *         } else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
- *             what = "MBean unregistered";
- *         } else if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION+".group")) {
- *             what = "Group of MBeans registered matching";
- *             if (mbsn.getUserData() instanceof ObjectName[])
- *                names =  (ObjectName[]) mbsn.getUserData();
- *         } else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION+".group")) {
- *             what = "Group of MBeans unregistered matching";
- *             if (mbsn.getUserData() instanceof ObjectName[])
- *                names = (ObjectName[]) mbsn.getUserData();
- *         } else
- *             what = "Unknown type " + n.getType();
- *         System.out.println("Received MBean Server notification: " + what + ": " +
- *                 mbsn.getMBeanName());
- *         if (names != null) {
- *              for (ObjectName mb : names)
- *                  System.out.println("\t"+mb);
- *         }
- *     }
- * };
- *
- * ...
- *     mbeanServer.addNotificationListener(
- *             JMXNamespaces.getNamespaceObjectName("foo"), printListener, null, null);
- * </pre>
  *
  * @since 1.5
  */