クラス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
関連項目:
  • フィールドのサマリー

    フィールド
    修飾子と型
    フィールド
    説明
    static final String
    MBeanが登録されたことを示す通知型です。
    static final String
    MBeanの登録が解除されたことを示す通知型です。

    クラス Notificationで宣言されたフィールド

    source
    修飾子と型
    フィールド
    説明
    protected Object
    このフィールドは、親クラスでEventObject.sourceフィールドを隠すことにより非transientになり、直列化形式の一部になります。
  • コンストラクタのサマリー

    コンストラクタ
    コンストラクタ
    説明
    MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName)
    通知と指定の通知型を発行したMBeanのオブジェクト名を指定する、MBeanServerNotificationオブジェクトを作成します。
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    通知を発行したMBeanのオブジェクト名を返します。

    クラス Notificationで宣言されたメソッド

    getMessage, getSequenceNumber, getTimeStamp, getType, getUserData, setSequenceNumber, setSource, setTimeStamp, setUserData, toString
    修飾子と型
    メソッド
    説明
    通知メッセージを取得します。
    long
    通知シーケンス番号を取得します。
    long
    通知タイムスタンプを取得します。
    通知型を取得します。
    ユーザー・データを取得します。
    void
    setSequenceNumber(long sequenceNumber)
    通知シーケンス番号を設定します。
    void
    setSource(Object source)
    ソースを設定します。
    void
    setTimeStamp(long timeStamp)
    通知タイムスタンプを設定します。
    void
    setUserData(Object userData)
    ユーザー・データを設定します。
    この通知のString表現を返します。

    クラスで宣言されたメソッド EventObject

    getSource
    修飾子と型
    メソッド
    説明
    Eventが最初に発生したオブジェクト。

    クラスオブジェクトで宣言されたメソッド

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    修飾子と型
    メソッド
    説明
    protected Object
    このオブジェクトのコピーを作成して、返します。
    boolean
    このオブジェクトと他のオブジェクトが等しいかどうかを示します。
    protected void
    削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。
    最終決定は非推奨であり、将来のリリースで削除される可能性があります。
    final Class<?>
    このObjectの実行時クラスを返します。
    int
    このオブジェクトに対するハッシュ・コード値を返します。
    final void
    このオブジェクトのモニターで待機中のスレッドを1つ再開します。
    final void
    このオブジェクトのモニターで待機中のすべてのスレッドを再開します。
    final void
    現在のスレッドが目覚めるまで待機します。通常、notifiedまたはinterruptedです。
    final void
    wait(long timeoutMillis)
    現在のスレッドは、通常、notifiedまたはinterruptedであるか、一定のリアルタイムが経過するまで、目覚めるまで待機します。
    final void
    wait(long timeoutMillis, int nanos)
    現在のスレッドは、通常、notifiedまたはinterruptedであるか、一定のリアルタイムが経過するまで、目覚めるまで待機します。
  • フィールド詳細

    • REGISTRATION_NOTIFICATION

      public static final String REGISTRATION_NOTIFICATION
      MBeanが登録されたことを示す通知型です。 値は「JMX.mbean.registered」になります。
      関連項目:
    • UNREGISTRATION_NOTIFICATION

      public static final String UNREGISTRATION_NOTIFICATION
      MBeanの登録が解除されたことを示す通知型です。 値は「JMX.mbean.unregistered」になります。
      関連項目:
  • コンストラクタの詳細

    • MBeanServerNotification

      public MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName)
      通知と指定の通知型を発行したMBeanのオブジェクト名を指定する、MBeanServerNotificationオブジェクトを作成します。
      パラメータ:
      type - 通知型を表す文字列。 REGISTRATION_NOTIFICATIONまたはUNREGISTRATION_NOTIFICATIONに設定する。
      source - MBeanサーバー通知を転送するMBeanServerNotificationオブジェクト。
      sequenceNumber - 受信した通知の並べ替えに使用できるシーケンス番号。
      objectName - 通知を発行したMBeanのオブジェクト名。
  • メソッドの詳細

    • getMBeanName

      public ObjectName getMBeanName()
      通知を発行したMBeanのオブジェクト名を返します。
      戻り値:
      通知を発行したMBeanのオブジェクト名。