クラス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 StringMBeanが登録されたことを示す通知型です。static final StringMBeanの登録が解除されたことを示す通知型です。クラスjavax.management.Notificationで宣言されたフィールド
source -
コンストラクタのサマリー
コンストラクタコンストラクタ説明MBeanServerNotification(String type, Object source, long sequenceNumber, ObjectName objectName) 通知と指定の通知型を発行したMBeanのオブジェクト名を指定する、MBeanServerNotificationオブジェクトを作成します。 -
メソッドのサマリー
クラスjavax.management.Notificationで宣言されたメソッド
getMessage, getSequenceNumber, getTimeStamp, getType, getUserData, setSequenceNumber, setSource, setTimeStamp, setUserData, toStringクラスjava.util.EventObjectで宣言されたメソッド
getSource
-
フィールド詳細
-
コンストラクタの詳細
-
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
-