JavaTM 2 Platform
Standard Ed. 6

javax.management
类 StandardEmitterMBean

java.lang.Object
  继承者 javax.management.StandardMBean
      继承者 javax.management.StandardEmitterMBean
所有已实现的接口:
DynamicMBean, MBeanRegistration, NotificationBroadcaster, NotificationEmitter

public class StandardEmitterMBean
extends StandardMBean
implements NotificationEmitter

一个其管理接口由 Java 接口上的反射确定并且可以发送通知的 MBean。

以下示例显示了如何使用公共构造方法 StandardEmitterMBean(implementation, mbeanInterface, emitter) 创建一个 MBean,使之能使用实现类名称 Impl、接口 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);
     

从以下版本开始:
1.6
另请参见:
StandardMBean

构造方法摘要
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 中添加一个侦听器。
 MBeanNotificationInfo[] getNotificationInfo()
          返回一个数组,指示此 MBean 可能发送的每个通知的 Java 类名和通知类型。
 void removeNotificationListener(NotificationListener listener)
          从此 MBean 移除一个侦听器。
 void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
          从此 MBean 移除一个侦听器。
 void sendNotification(Notification n)
          发送通知。
 
从类 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
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

StandardEmitterMBean

public StandardEmitterMBean(T implementation,
                            Class<T> mbeanInterface,
                            NotificationEmitter emitter)

构造一个 MBean,其管理接口由 mbeanInterface 使用给定实现指定,并且其中的通知由给定的 NotificationEmitter 处理。结果 MBean 通过将其方法转发给 emitter 来实现 NotificationEmitter 接口。这是合法的,并且在将 implementationemitter 用于相同对象时很有用。

如果 emitterNotificationBroadcasterSupport 的实例,则该 MBean 的 sendNotification 方法将调用 emitter.sendNotification

由新 MBean 上的 getNotificationInfo() 返回的数组是进行构造时由 emitter.getNotificationInfo() 返回的数组的副本。如果由 emitter.getNotificationInfo() 返回的数组之后发生变化,那么这种变化不会影响到此对象的 getNotificationInfo()

参数:
implementation - MBean 接口的实现。
mbeanInterface - Standard MBean 接口。
emitter - 将处理通知的对象。
抛出:
IllegalArgumentException - 如果 mbeanInterface 不遵守管理接口的 JMX 设计模式,或者给定的 implementation 没有实现指定的接口,抑或 emitter 为 null。

StandardEmitterMBean

public StandardEmitterMBean(T implementation,
                            Class<T> mbeanInterface,
                            boolean isMXBean,
                            NotificationEmitter emitter)

构造一个 MBean,其管理接口由 mbeanInterface 使用给定实现指定,并且其中的通知由给定的 NotificationEmitter 处理。此构造方法可以用于构造 Standard MBean 或 MXBean。结果 MBean 通过将其方法转发给 emitter 来实现 NotificationEmitter 接口。这是合法的,并且在将 implementationemitter 用于相同对象时很有用。

如果 emitterNotificationBroadcasterSupport 的实例,则该 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。

StandardEmitterMBean

protected StandardEmitterMBean(Class<?> mbeanInterface,
                               NotificationEmitter emitter)

构造一个 MBean,其管理接口由 mbeanInterface 指定,并且其中的通知由给定的 NotificationEmitter 处理。结果 MBean 通过将其方法转发给 emitter 来实现 NotificationEmitter 接口。

如果 emitterNotificationBroadcasterSupport 的实例,则该 MBean 的 sendNotification 方法将调用 emitter.sendNotification

由新 MBean 上的 getNotificationInfo() 返回的数组是进行构造时由 emitter.getNotificationInfo() 返回的数组的副本。如果由 emitter.getNotificationInfo() 返回的数组之后发生变化,那么这种变化不会影响到此对象的 getNotificationInfo()

此构造方法必须从实现给定 mbeanInterface 的子类调用。

参数:
mbeanInterface - StandardMBean 接口。
emitter - 将处理通知的对象。
抛出:
IllegalArgumentException - 如果 mbeanInterface 不遵守管理接口的 JMX 设计模式,或者给定的 this 没有实现指定的接口,抑或 emitter 为 null。

StandardEmitterMBean

protected StandardEmitterMBean(Class<?> mbeanInterface,
                               boolean isMXBean,
                               NotificationEmitter emitter)

构造一个 MBean,其管理接口由 mbeanInterface 指定,并且其中的通知由给定的 NotificationEmitter 处理。此构造方法可以用于构造 Standard MBean 或 MXBean。结果 MBean 通过将其方法转发给 emitter 来实现 NotificationEmitter 接口。

如果 emitterNotificationBroadcasterSupport 的实例,则该 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。
方法详细信息

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
从接口 NotificationBroadcaster 复制的描述
从此 MBean 移除一个侦听器。如果已向不同的 handback 对象或通知过滤器注册了该侦听器,则移除与该侦听器有关的所有项。

指定者:
接口 NotificationBroadcaster 中的 removeNotificationListener
参数:
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)

removeNotificationListener

public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws ListenerNotFoundException
从接口 NotificationEmitter 复制的描述

从此 MBean 移除一个侦听器。该 MBean 必须有一个与给定 listenerfilterhandback 参数完全匹配的侦听器。如果有多个此类侦听器,则只移除一个侦听器。

当且仅当在要移除的侦听器中 filterhandback 参数为 null 时,这两个参数才可以为 null。

指定者:
接口 NotificationEmitter 中的 removeNotificationListener
参数:
listener - 以前添加到此 MBean 中的侦听器。
filter - 添加侦听器时指定的过滤器。
handback - 添加侦听器时指定的回送。
抛出:
ListenerNotFoundException - 如果没有在该 MBean 中注册侦听器,或者没有用给定的过滤器和回送注册它。

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
从接口 NotificationBroadcaster 复制的描述
在此 MBean 中添加一个侦听器。

指定者:
接口 NotificationBroadcaster 中的 addNotificationListener
参数:
listener - 将处理广播者发出的通知的侦听器对象。
filter - 过滤器对象。如果 filter 为 null,则处理通知前不执行过滤。
handback - 发出通知时要发送回侦听器的不透明对象。Notification 广播者对象不能使用此对象。应该将通知不作更改地重新发送到侦听器。
另请参见:
NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
从接口 NotificationBroadcaster 复制的描述

返回一个数组,指示此 MBean 可能发送的每个通知的 Java 类名和通知类型。

MBean 发送此数组中未描述的通知是合法的。但是,某些 MBean 服务器的客户端要想正常运行,可能要依赖完整的数组。

指定者:
接口 NotificationBroadcaster 中的 getNotificationInfo
返回:
可能的通知数组。

sendNotification

public void sendNotification(Notification n)

发送通知。

如果构造方法的 emitter 参数是一个 NotificationBroadcasterSupport 实例,则此方法将调用 emitter.sendNotification

参数:
n - 要发送的通知。
抛出:
ClassCastException - 如果构造方法的 emitter 参数不是 NotificationBroadcasterSupport

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only