public class MBeanServerNotification extends Notification
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 により MBeanNotificationInfo 内に宣言されます。
| 修飾子と型 | フィールドと説明 |
|---|---|
static String |
REGISTRATION_NOTIFICATION
MBean が登録されたことを示す通知型です。
|
static String |
UNREGISTRATION_NOTIFICATION
MBean の登録が解除されたことを示す通知型です。
|
source| コンストラクタと説明 |
|---|
MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName)
通知と指定の通知型を発行した MBean のオブジェクト名を指定する、MBeanServerNotification オブジェクトを作成します。
|
| 修飾子と型 | メソッドと説明 |
|---|---|
ObjectName |
getMBeanName()
通知を発行した MBean のオブジェクト名を返します。
|
String |
toString()
この通知の String 表現を返します。
|
getMessage, getSequenceNumber, getTimeStamp, getType, getUserData, setSequenceNumber, setSource, setTimeStamp, setUserDatagetSourcepublic static final String REGISTRATION_NOTIFICATION
public MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName)
type - 通知型を表す文字列。REGISTRATION_NOTIFICATION または UNREGISTRATION_NOTIFICATION に設定する。source - MBean サーバー通知を転送する MBeanServerNotification オブジェクト。sequenceNumber - 受信した通知の並べ替えに使用できるシーケンス番号。objectName - 通知を発行した MBean のオブジェクト名。public ObjectName getMBeanName()
public String toString()
NotificationtoString、クラス: Notification バグまたは機能を送信
詳細な API リファレンスおよび開発者ドキュメントについては、Java SE のドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.