モジュール java.management
パッケージ javax.management

クラスMBeanServerNotification

java.lang.Object
java.util.EventObject
javax.management.Notification
javax.management.MBeanServerNotification
すべての実装されたインタフェース:
Serializable

public class MBeanServerNotification extends Notification
MBeanサーバーにより、MBeanServerDelegate MBeanから発行される通知を表します。 MBeanサーバーは、MBean登録型またはMBean登録解除型の通知を発行します。

MBeanServerNotificationを受信するには、MBeanServerを表すMBean、MBeanServerDelegateにリスナーを登録する必要があります。 MBeanServerDelegateのObjectNameは、JMImplementation:type=MBeanServerDelegateであるMBeanServerDelegate.DELEGATE_NAMEです。

次のコードは、MBeanサーバーmbeanServerにMBeanが登録または登録解除されるたびにメッセージを出力します。

 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;
         if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION))
             what = "MBean registered";
         else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION))
             what = "MBean unregistered";
         else
             what = "Unknown type " + n.getType();
         System.out.println("Received MBean Server notification: " + what + ": " +
                 mbsn.getMBeanName());
     }
 };

 ...
     mbeanServer.addNotificationListener(
             MBeanServerDelegate.DELEGATE_NAME, printListener, null, null);
 

MBeanServerDelegate以外のMBeanもMBeanServerNotificationを発行できます。 特に、MBeanがMBeanのグループのMBeanServerNotificationを発行する規則があります。

MBeanのグループの登録または登録解除を示すために発行されたMBeanServerNotificationには、次の特徴があります。

  • 通知型"JMX.mbean.registered.group"または"JMX.mbean.unregistered.group"であり、通知型にREGISTRATION_NOTIFICATION+".group"またはUNREGISTRATION_NOTIFICATION+".group"を書き込むこともできる。
  • MBean名は、登録または登録解除されたMBeanのセット(またはスーパー・セット)を選択するObjectNameパターンである
  • オプションで、ユーザー・データを、登録または登録解除されたすべてのMBeanの名前を含むObjectNameの配列に設定できる。

MBeanグループの登録/登録解除の通知は、それを発行するMBeanによりMBeanNotificationInfo内に宣言されます。

導入されたバージョン:
1.5
関連項目: