public class StandardEmitterMBean extends StandardMBean implements NotificationEmitter
一个MBean,其管理界面由Java接口上的反射决定,并发出通知。
以下示例显示如何使用公共构造函数StandardEmitterMBean(implementation, mbeanInterface, emitter)创建使用任何实现类名称Impl发布通知的MBean,通过任何接口Intf定义管理接口(如当前标准MBean),以及任何接口NotificationEmitter的实现 。 该示例使用类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
| Modifier | Constructor and Description |
|---|---|
protected |
StandardEmitterMBean(类<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
制作一个MBean,其管理界面由
mbeanInterface ,通知由给定的
NotificationEmitter处理。
|
protected |
StandardEmitterMBean(类<?> mbeanInterface, NotificationEmitter emitter)
制作一个MBean,其管理界面由
mbeanInterface ,通知由给定的
NotificationEmitter处理。
|
|
StandardEmitterMBean(T implementation, 类<T> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
制定一个MBean,其管理界面由
mbeanInterface ,给定的实现和通知由给定的
NotificationEmitter处理。
|
|
StandardEmitterMBean(T implementation, 类<T> mbeanInterface, NotificationEmitter emitter)
制作一个MBean,其管理界面由
mbeanInterface ,给定的实现和通知由给定的
NotificationEmitter处理。
|
| Modifier and Type | Method and Description |
|---|---|
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,
类<T> mbeanInterface,
NotificationEmitter emitter)
制作一个MBean,其管理界面由mbeanInterface ,给定的实现和通知由给定的NotificationEmitter处理。 将所得的MBean实现NotificationEmitter通过将其方法转发到接口emitter 。 对于implementation和emitter是同一个对象是合法有用的。
如果emitter是实例NotificationBroadcasterSupport则MBean的sendNotification方法将调用emitter. sendNotification 。
通过返回的数组getNotificationInfo()在新的MBean是返回数组的副本emitter. getNotificationInfo()在施工时间。 如果由emitter.getNotificationInfo()返回的emitter.getNotificationInfo()稍后更改,那将对此对象的getNotificationInfo()没有影响。
implementation - MBean接口的实现。
mbeanInterface - 一个标准的MBean接口。
emitter - 将处理通知的对象。
IllegalArgumentException - 如果
mbeanInterface不遵循管理接口的JMX设计模式,或者给定的
implementation未实现指定的接口,或者如果
emitter为空。
public StandardEmitterMBean(T implementation,
类<T> mbeanInterface,
boolean isMXBean,
NotificationEmitter emitter)
制作一个MBean,其管理界面由mbeanInterface ,给定的实现和通知由给定的NotificationEmitter处理。 此构造函数可用于创建标准MBean或MXBean。 将所得的MBean实现NotificationEmitter通过将其方法转发到接口emitter 。 对于implementation和emitter是相同的对象是合法有用的。
如果emitter是实例NotificationBroadcasterSupport则MBean的sendNotification方法将调用emitter. sendNotification 。
通过返回的数组getNotificationInfo()在新的MBean是返回数组的副本emitter. getNotificationInfo()在施工时间。 如果由emitter.getNotificationInfo()返回的emitter.getNotificationInfo()稍后更改,那将对此对象的getNotificationInfo()没有影响。
implementation - MBean接口的实现。
mbeanInterface - 一个标准的MBean接口。
isMXBean - 如果为true,那么
mbeanInterface参数命名一个MXBean接口,结果MBean是一个MXBean。
emitter - 将处理通知的对象。
IllegalArgumentException - 如果
mbeanInterface不遵循管理接口的JMX设计模式,或者给定的
implementation未实现指定的接口,或者如果
emitter为空。
protected StandardEmitterMBean(类<?> mbeanInterface, NotificationEmitter emitter)
制作一个MBean,其管理界面由mbeanInterface ,通知由给定的NotificationEmitter处理。 将所得的MBean实现NotificationEmitter通过将其方法转发到接口emitter 。
如果emitter是实例NotificationBroadcasterSupport则MBean的sendNotification方法将调用emitter. sendNotification 。
通过返回的数组getNotificationInfo()在新的MBean是返回数组的副本emitter. getNotificationInfo()在施工时间。 如果由emitter.getNotificationInfo()返回的emitter.getNotificationInfo()稍后更改,那将对此对象的getNotificationInfo()没有影响。
必须从实现给定mbeanInterface的子类调用此构造mbeanInterface 。
mbeanInterface - 一个StandardMBean界面。
emitter - 将处理通知的对象。
IllegalArgumentException - 如果
mbeanInterface不遵循管理接口的JMX设计模式,或者如果
this未实现指定的接口,或者如果
emitter为空。
protected StandardEmitterMBean(类<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
制作一个MBean,其管理界面由mbeanInterface ,通知由给定的NotificationEmitter处理。 此构造函数可用于创建标准MBean或MXBean。 将所得的MBean实现NotificationEmitter通过将其方法转发到接口emitter 。
如果emitter是实例NotificationBroadcasterSupport则MBean的sendNotification方法将调用emitter. sendNotification 。
通过返回的数组getNotificationInfo()在新的MBean是返回数组的副本emitter. getNotificationInfo()在施工时间。 如果由emitter.getNotificationInfo()返回的emitter.getNotificationInfo()稍后更改,那将对此对象的getNotificationInfo()没有影响。
必须从实现给定mbeanInterface的子类调用此构造mbeanInterface 。
mbeanInterface - 一个StandardMBean界面。
isMXBean - 如果为true,那么
mbeanInterface参数命名一个MXBean接口,结果MBean是一个MXBean。
emitter - 将处理通知的对象。
IllegalArgumentException - 如果
mbeanInterface不遵循管理接口的JMX设计模式,或者如果
this未实现指定的接口,或者如果
emitter为空。
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
NotificationBroadcaster复制
removeNotificationListener在接口
NotificationBroadcaster
listener - 以前添加到此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参数。 如果有多个这样的听众,只有一个被删除。
filter和handback参数可以为null,当且仅当它们在要删除的侦听器中为空时。
removeNotificationListener在接口
NotificationEmitter
listener - 以前添加到此MBean的侦听器。
filter - 添加侦听器时指定的过滤器。
handback - 添加侦听器时指定的回调。
ListenerNotFoundException - 监听器未注册到MBean,或者没有向给定的过滤器和回传注册。
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
NotificationBroadcaster
addNotificationListener在接口
NotificationBroadcaster
listener - 将处理广播公司发出的通知的侦听器对象。
filter - 过滤器对象。
如果过滤器为空,则在处理通知之前不会执行过滤。
handback - 发出通知时发送回侦听器的不透明对象。
该通知广播对象无法使用此对象。
通知发送者应该重新发送更改。
NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)
public MBeanNotificationInfo[] getNotificationInfo()
NotificationBroadcaster
返回一个数组,指示MBean可能发送的每个通知,通知的Java类的名称和通知类型。
MBean发送不在此阵列中描述的通知并不是非法的。 但是,MBean服务器的某些客户端可能依赖于正确运行的阵列。
getNotificationInfo在接口
NotificationBroadcaster
public void sendNotification(Notification n)
发送通知。
如果emitter参数构造函数是实例NotificationBroadcasterSupport ,则此方法将调用emitter. sendNotification 。
n - 发送通知。
ClassCastException - 如果
emitter函数的emitter参数不是
NotificationBroadcasterSupport 。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.