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, setUserData
getSource
public 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()
Notification
toString
、クラスNotification
バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。