- 所有已实现的接口:
DynamicMBean
,MBeanRegistration
,NotificationBroadcaster
,NotificationEmitter
一个 MBean,其管理接口由 Java 接口上的反射决定,并发出通知。
以下示例显示如何使用公共构造函数 StandardEmitterMBean(implementation, mbeanInterface, emitter)
创建一个 MBean 发出具有任何实现类名称的通知实施,具有由任何接口定义的管理接口(对于当前标准 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);
- 自从:
- 1.6
- 参见:
-
构造方法总结
构造方法修饰符构造方法描述protected
StandardEmitterMBean
(Class<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter) 创建一个 MBean,其管理接口由mbeanInterface
指定,通知由给定的NotificationEmitter
处理。protected
StandardEmitterMBean
(Class<?> mbeanInterface, NotificationEmitter emitter) 创建一个 MBean,其管理接口由mbeanInterface
指定,通知由给定的NotificationEmitter
处理。StandardEmitterMBean
(T implementation, Class<T> mbeanInterface, boolean isMXBean, NotificationEmitter emitter) 创建一个 MBean,其管理接口由mbeanInterface
指定,具有给定的实现,通知由给定的NotificationEmitter
处理。StandardEmitterMBean
(T implementation, Class<T> mbeanInterface, NotificationEmitter emitter) 创建一个 MBean,其管理接口由mbeanInterface
指定,具有给定的实现,通知由给定的NotificationEmitter
处理。 -
方法总结
修饰符和类型方法描述void
addNotificationListener
(NotificationListener listener, NotificationFilter filter, Object handback) 向此 MBean 添加一个监听。返回一个数组,指示对于此 MBean 可能发送的每个通知,通知的 Java 类的名称和通知类型。void
从此 MBean 中移除监听。void
removeNotificationListener
(NotificationListener listener, NotificationFilter filter, Object handback) 从此 MBean 中移除监听。void
发送通知。在类 javax.management.StandardMBean 中声明的方法
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, setImplementation
-
构造方法详细信息
-
StandardEmitterMBean
public StandardEmitterMBean(T implementation, Class <T> mbeanInterface, NotificationEmitter emitter) 创建一个 MBean,其管理接口由
mbeanInterface
指定,具有给定的实现,通知由给定的NotificationEmitter
处理。生成的 MBean 通过将其方法转发给emitter
来实现NotificationEmitter
接口。implementation
和emitter
是同一个对象是合法且有用的。如果
emitter
是NotificationBroadcasterSupport
的实例,则 MBean 的sendNotification
方法将调用emitter.
sendNotification
。getNotificationInfo()
在新 MBean 上返回的数组是构造时emitter.
getNotificationInfo()
返回的数组的副本。如果emitter.getNotificationInfo()
返回的数组稍后发生变化,则不会影响此对象的getNotificationInfo()
。- 类型参数:
T
- MBean 的实现类型- 参数:
implementation
- MBean 接口的实现。mbeanInterface
- 标准 MBean 接口。emitter
- 将处理通知的对象。- 抛出:
IllegalArgumentException
- 如果mbeanInterface
不遵循管理接口的 JMX 设计模式,或者如果给定的implementation
没有实现指定的接口,或者如果emitter
为空。
-
StandardEmitterMBean
public StandardEmitterMBean(T implementation, Class <T> mbeanInterface, boolean isMXBean, NotificationEmitter emitter) 创建一个 MBean,其管理接口由
mbeanInterface
指定,具有给定的实现,通知由给定的NotificationEmitter
处理。此构造函数可用于生成标准 MBean 或 MXBeans。生成的 MBean 通过将其方法转发给emitter
来实现NotificationEmitter
接口。implementation
和emitter
是同一个对象是合法且有用的。如果
emitter
是NotificationBroadcasterSupport
的实例,则 MBean 的sendNotification
方法将调用emitter.
sendNotification
。getNotificationInfo()
在新 MBean 上返回的数组是构造时emitter.
getNotificationInfo()
返回的数组的副本。如果emitter.getNotificationInfo()
返回的数组稍后发生变化,则不会影响此对象的getNotificationInfo()
。- 类型参数:
T
- MBean 的实现类型- 参数:
implementation
- MBean 接口的实现。mbeanInterface
- 标准 MBean 接口。isMXBean
- 如果为真,mbeanInterface
参数命名一个 MXBean 接口,生成的 MBean 是一个 MXBean。emitter
- 将处理通知的对象。- 抛出:
IllegalArgumentException
- 如果mbeanInterface
不遵循管理接口的 JMX 设计模式,或者如果给定的implementation
没有实现指定的接口,或者如果emitter
为空。
-
StandardEmitterMBean
创建一个 MBean,其管理接口由
mbeanInterface
指定,通知由给定的NotificationEmitter
处理。生成的 MBean 通过将其方法转发给emitter
来实现NotificationEmitter
接口。如果
emitter
是NotificationBroadcasterSupport
的实例,则 MBean 的sendNotification
方法将调用emitter.
sendNotification
。getNotificationInfo()
在新 MBean 上返回的数组是构造时emitter.
getNotificationInfo()
返回的数组的副本。如果emitter.getNotificationInfo()
返回的数组稍后发生变化,则不会影响此对象的getNotificationInfo()
。必须从实现给定
mbeanInterface
的子类调用此构造函数。- 参数:
mbeanInterface
- 一个 StandardMBean 接口。emitter
- 将处理通知的对象。- 抛出:
IllegalArgumentException
- 如果mbeanInterface
不遵循管理接口的 JMX 设计模式,或者如果this
没有实现指定的接口,或者如果emitter
为空。
-
StandardEmitterMBean
protected StandardEmitterMBean(Class <?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter) 创建一个 MBean,其管理接口由
mbeanInterface
指定,通知由给定的NotificationEmitter
处理。此构造函数可用于生成标准 MBean 或 MXBeans。生成的 MBean 通过将其方法转发给emitter
来实现NotificationEmitter
接口。如果
emitter
是NotificationBroadcasterSupport
的实例,则 MBean 的sendNotification
方法将调用emitter.
sendNotification
。getNotificationInfo()
在新 MBean 上返回的数组是构造时emitter.
getNotificationInfo()
返回的数组的副本。如果emitter.getNotificationInfo()
返回的数组稍后发生变化,则不会影响此对象的getNotificationInfo()
。必须从实现给定
mbeanInterface
的子类调用此构造函数。- 参数:
mbeanInterface
- 一个 StandardMBean 接口。isMXBean
- 如果为真,mbeanInterface
参数命名一个 MXBean 接口,生成的 MBean 是一个 MXBean。emitter
- 将处理通知的对象。- 抛出:
IllegalArgumentException
- 如果mbeanInterface
不遵循管理接口的 JMX 设计模式,或者如果this
没有实现指定的接口,或者如果emitter
为空。
-
-
方法详情
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException 从接口NotificationBroadcaster
复制的描述从此 MBean 中移除监听。如果监听已注册到不同的交接对象或通知过滤器,则该监听对应的所有条目将被删除。- 指定者:
removeNotificationListener
在接口NotificationBroadcaster
中- 参数:
listener
- 先前添加到此 MBean 的监听器。- 抛出:
ListenerNotFoundException
- 监听器未在 MBean 中注册。- 参见:
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException 从接口NotificationEmitter
复制的描述从此 MBean 中移除监听器。 MBean 必须具有与给定的
listener
、filter
和handback
参数完全匹配的监听器。如果有多个这样的监听器,则只删除一个。当且仅当它们在要删除的监听器中为空时,
filter
和handback
参数可以为空。- 指定者:
removeNotificationListener
在接口NotificationEmitter
中- 参数:
listener
- 先前添加到此 MBean 的监听器。filter
- 添加监听器时指定的过滤器。handback
- 添加监听器时指定的交接。- 抛出:
ListenerNotFoundException
- 监听器未在 MBean 中注册,或者未在给定的过滤器和 handback 中注册。
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) 从接口NotificationBroadcaster
复制的描述向此 MBean 添加一个监听。- 指定者:
addNotificationListener
在接口NotificationBroadcaster
中- 参数:
listener
- 将处理广播者发出的通知的监听器对象。filter
- 过滤器对象。如果 filter 为 null,则在处理通知之前不会执行任何过滤。handback
- 发出通知时要发送回监听器的不透明对象。通知广播对象不能使用该对象。它应该与通知收听者的通知一起重新发送。- 参见:
-
getNotificationInfo
从接口NotificationBroadcaster
复制的描述返回一个数组,指示对于此 MBean 可能发送的每个通知,通知的 Java 类的名称和通知类型。
MBean 发送此数组中未描述的通知并不是非法的。但是,MBean 服务的某些客户端可能依赖于完整的数组才能正常运行。
- 指定者:
getNotificationInfo
在接口NotificationBroadcaster
中- 返回:
- 可能通知的数组。
-
sendNotification
发送通知。
如果构造函数的
emitter
参数是NotificationBroadcasterSupport
的实例,则此方法将调用emitter.
sendNotification
。- 参数:
n
- 要发送的通知。- 抛出:
ClassCastException
- 如果构造函数的emitter
参数不是NotificationBroadcasterSupport
。
-