public class StandardEmitterMBean extends StandardMBean implements NotificationEmitter
Javaインタフェースのリフレクションによって管理インタフェースを決定し、通知を発行するMBeanです。
次の例は、publicコンストラクタStandardEmitterMBean(implementation, mbeanInterface, emitter)を使用して、任意の実装クラス名Impl、任意のインタフェースIntfで定義された管理インタフェース(現在のStandard MBean用)、およびインタフェースNotificationEmitterの任意の実装を指定し、通知を発行するMBeanを作成する方法を示しています。この例では、NotificationBroadcasterSupportクラスをインタフェースNotificationEmitterの実装として使用します。
MBeanServer mbs;
...
final String[] types = new String[] {"sun.disc.space","sun.disc.alarm"};
final MBeanNotificationInfo info = new MBeanNotificationInfo(
types,
Notification.class.getName(),
"Notification about disc info.");
final NotificationEmitter emitter =
new NotificationBroadcasterSupport(info);
final Intf impl = new Impl(...);
final Object mbean = new StandardEmitterMBean(
impl, Intf.class, emitter);
mbs.registerMBean(mbean, objectName);
StandardMBean| 修飾子 | コンストラクタと説明 |
|---|---|
protected |
StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
管理インタフェースが
mbeanInterfaceで指定されたMBeanを作成します。通知は、指定したNotificationEmitterにより処理されます。 |
protected |
StandardEmitterMBean(Class<?> mbeanInterface, NotificationEmitter emitter)
管理インタフェースが
mbeanInterfaceで指定されたMBeanを作成します。通知は、指定したNotificationEmitterにより処理されます。 |
|
StandardEmitterMBean(T implementation, Class<T> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
指定された実装を持ち、指定された
NotificationEmitterで通知が処理される、管理インタフェースがmbeanInterfaceで指定されたMBeanを作成します。 |
|
StandardEmitterMBean(T implementation, Class<T> mbeanInterface, NotificationEmitter emitter)
指定された実装を持ち、指定された
NotificationEmitterで通知が処理される、管理インタフェースがmbeanInterfaceで指定されたMBeanを作成します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
void |
addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
このMBeanにリスナーを追加します。
|
MBeanNotificationInfo[] |
getNotificationInfo()
このMBeanが送信する可能性のある各通知について、その通知のJavaクラス名と通知型を示す配列を返します。
|
void |
removeNotificationListener(NotificationListener listener)
このMBeanからリスナーを削除します。
|
void |
removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
このMBeanからリスナーを削除します。
|
void |
sendNotification(Notification n)
通知を送信します。
|
cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, getParameterName, getParameterName, invoke, postDeregister, postRegister, preDeregister, preRegister, setAttribute, setAttributes, setImplementationpublic StandardEmitterMBean(T implementation,
Class<T> mbeanInterface,
NotificationEmitter emitter)
指定された実装を持ち、指定されたNotificationEmitterで通知が処理される、管理インタフェースがmbeanInterfaceで指定されたMBeanを作成します。生成されるMBeanは、そのメソッドをemitterに転送することにより、NotificationEmitterインタフェースを実装します。implementationおよびemitterを同じオブジェクトにすることは、正当で有用です。
emitterがNotificationBroadcasterSupportのインスタンスである場合、MBeanのsendNotificationメソッドはemitter.sendNotificationを呼び出します。
新規MBeanでgetNotificationInfo()により返される配列は、構築時にemitter.getNotificationInfo()により返される配列のコピーです。emitter.getNotificationInfo()により返された配列があとで変更されても、オブジェクトのgetNotificationInfo()が影響を受けることはありません。
implementation - MBeanインタフェースの実装。mbeanInterface - Standard MBeanインタフェース。emitter - 通知を処理するオブジェクト。IllegalArgumentException - mbeanInterfaceが管理インタフェースのJMX設計パターンに従っていない場合、指定されたimplementationが指定されたインタフェースを実装していない場合、またはemitterがnullの場合。public StandardEmitterMBean(T implementation,
Class<T> mbeanInterface,
boolean isMXBean,
NotificationEmitter emitter)
指定された実装を持ち、指定されたNotificationEmitterで通知が処理される、管理インタフェースがmbeanInterfaceで指定されたMBeanを作成します。このコンストラクタは、Standard MBeanまたはMXBeanの作成に使用できます。生成されるMBeanは、そのメソッドをemitterに転送することにより、NotificationEmitterインタフェースを実装します。implementationおよびemitterを同じオブジェクトにすることは、正当で有用です。
emitterがNotificationBroadcasterSupportのインスタンスである場合、MBeanのsendNotificationメソッドはemitter.sendNotificationを呼び出します。
新規MBeanでgetNotificationInfo()により返される配列は、構築時にemitter.getNotificationInfo()により返される配列のコピーです。emitter.getNotificationInfo()により返された配列があとで変更されても、オブジェクトのgetNotificationInfo()が影響を受けることはありません。
implementation - MBeanインタフェースの実装。mbeanInterface - Standard MBeanインタフェース。isMXBean - trueの場合、mbeanInterfaceパラメータによりMXBeanインタフェースが指定され、結果のMBeanはMXBeanになる。emitter - 通知を処理するオブジェクト。IllegalArgumentException - mbeanInterfaceが管理インタフェースのJMX設計パターンに従っていない場合、指定されたimplementationが指定されたインタフェースを実装していない場合、またはemitterがnullの場合。protected StandardEmitterMBean(Class<?> mbeanInterface, NotificationEmitter emitter)
管理インタフェースがmbeanInterfaceで指定されたMBeanを作成します。通知は、指定したNotificationEmitterにより処理されます。生成されるMBeanは、そのメソッドをemitterに転送することにより、NotificationEmitterインタフェースを実装します。
emitterがNotificationBroadcasterSupportのインスタンスである場合、MBeanのsendNotificationメソッドはemitter.sendNotificationを呼び出します。
新規MBeanでgetNotificationInfo()により返される配列は、構築時にemitter.getNotificationInfo()により返される配列のコピーです。emitter.getNotificationInfo()により返された配列があとで変更されても、オブジェクトのgetNotificationInfo()が影響を受けることはありません。
このコンストラクタの呼出しは、指定したmbeanInterfaceを実装するサブクラスから行う必要があります。
mbeanInterface - StandardMBeanインタフェース。emitter - 通知を処理するオブジェクト。IllegalArgumentException - mbeanInterfaceが管理インタフェースのJMX設計パターンに従っていない場合、thisが指定されたインタフェースを実装していない場合、またはemitterがnullの場合。protected StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
管理インタフェースがmbeanInterfaceで指定されたMBeanを作成します。通知は、指定したNotificationEmitterにより処理されます。このコンストラクタは、Standard MBeanまたはMXBeanの作成に使用できます。生成されるMBeanは、そのメソッドをemitterに転送することにより、NotificationEmitterインタフェースを実装します。
emitterがNotificationBroadcasterSupportのインスタンスである場合、MBeanのsendNotificationメソッドはemitter.sendNotificationを呼び出します。
新規MBeanでgetNotificationInfo()により返される配列は、構築時にemitter.getNotificationInfo()により返される配列のコピーです。emitter.getNotificationInfo()により返された配列があとで変更されても、オブジェクトのgetNotificationInfo()が影響を受けることはありません。
このコンストラクタの呼出しは、指定したmbeanInterfaceを実装するサブクラスから行う必要があります。
mbeanInterface - StandardMBeanインタフェース。isMXBean - trueの場合、mbeanInterfaceパラメータによりMXBeanインタフェースが指定され、結果のMBeanはMXBeanになる。emitter - 通知を処理するオブジェクト。IllegalArgumentException - mbeanInterfaceが管理インタフェースのJMX設計パターンに従っていない場合、thisが指定されたインタフェースを実装していない場合、またはemitterがnullの場合。public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
NotificationBroadcasterremoveNotificationListener、インタフェース: NotificationBroadcasterlistener - 以前にこのMBeanに追加されたリスナー。ListenerNotFoundException - リスナーがMBeanに登録されていない場合。NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), NotificationEmitter.removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException
NotificationEmitterこのMBeanからリスナーを削除します。MBeanは、指定されたlistener、filter、およびhandbackパラメータと正確に一致するリスナーを持っている必要があります。該当するリスナーが複数存在する場合、そのうちの1つだけが削除されます。
削除されるリスナー内でnullが指定されている場合にのみ、filterおよびhandbackパラメータはnullになります。
removeNotificationListener、インタフェース: NotificationEmitterlistener - 以前にこのMBeanに追加されたリスナー。filter - リスナーの追加時に指定されたフィルタ。handback - リスナーの追加時に指定されたハンドバック。ListenerNotFoundException - リスナーがMBeanに登録されていない場合、または指定されたフィルタおよびハンドバックで登録されていない場合。public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
NotificationBroadcasteraddNotificationListener、インタフェース: NotificationBroadcasterlistener - ブロードキャスタが発行した通知を処理するリスナー・オブジェクト。filter - フィルタ・オブジェクト。フィルタがnullの場合、通知処理の前にフィルタは適用されない。handback - 通知の発行時にリスナーに送信される不透明なオブジェクト。Notificationブロードキャスタ・オブジェクトは、このオブジェクトを使用できない。このオブジェクトは、手を加えない状態で、通知とともにリスナーへ送り返されなければならない。NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)public MBeanNotificationInfo[] getNotificationInfo()
NotificationBroadcasterこのMBeanが送信する可能性のある各通知について、その通知のJavaクラス名と通知型を示す配列を返します。
この配列に記述されていない通知をMBeanが送信しても、不正ではありません。ただし一部のMBeanサーバー・クライアントは、正しく機能するために、作成される配列に依存する場合があります。
getNotificationInfo、インタフェース: NotificationBroadcasterpublic void sendNotification(Notification n)
通知を送信します。
コンストラクタに渡されるemitterパラメータがNotificationBroadcasterSupportのインスタンスであった場合、このメソッドはemitter.sendNotificationを呼び出します。
n - 送信する通知。ClassCastException - コンストラクタに渡されるemitterパラメータがNotificationBroadcasterSupportでなかった場合。 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright© 1993, 2014, Oracle and/or its affiliates. All rights reserved.