类 NotificationBroadcasterSupport

java.lang.Object
javax.management.NotificationBroadcasterSupport
所有已实现的接口:
NotificationBroadcaster , NotificationEmitter
已知子类:
JMXConnectorServer , Monitor , RelationService , Timer

public class NotificationBroadcasterSupport extends Object implements NotificationEmitter

提供 NotificationEmitter 接口的实现。这可以用作发送通知的 MBean 的超类。

默认情况下,通知分发模型是同步的。也就是说,当一个线程调用 sendNotification 时,每个监听器的 NotificationListener.handleNotification 方法都会在该线程内调用。您可以通过在子类中覆盖 handleNotification 或将 Executor 传递给构造函数来覆盖此默认值。

如果过滤器或监听器的方法调用抛出 Exception ,则该异常不会阻止调用其他监听器。但是,如果过滤器或 Executor.executehandleNotification 的方法调用(当未指定 Executor 时)抛出 Error ,则该 Error 将传播到 sendNotification 的调用者。

使用 JMX 远程 API(请参阅 JMXConnector)添加的远程监听通常不会被同步调用。也就是说,当 sendNotification 返回时,不能保证任何远程监听都已经收到通知。

自从:
1.5
  • 构造方法详细信息

    • NotificationBroadcasterSupport

      public NotificationBroadcasterSupport()
      构造一个 NotificationBroadcasterSupport,其中每个监听器都由发送通知的线程调用。此构造函数等效于 NotificationBroadcasterSupport(null, null)
    • NotificationBroadcasterSupport

      public NotificationBroadcasterSupport(Executor  executor)
      构造一个 NotificationBroadcasterSupport,其中使用给定的 Executor 调用每个监听器。调用 sendNotification 时,如果添加了空值 NotificationFilter isNotificationEnabled 为发送的通知返回 true,则选择一个监听器。对 NotificationFilter.isNotificationEnabled 的调用发生在调用 sendNotification 的线程中。然后,对于每个选定的监听器,使用调用 handleNotification 方法的命令调用 executor.execute 。此构造函数等效于 NotificationBroadcasterSupport(executor, null)
      参数:
      executor - 方法 sendNotification 用于发送每个通知的执行程序。如果它为 null,调用 sendNotification 的线程将调用 handleNotification 方法本身。
      自从:
      1.6
    • NotificationBroadcasterSupport

      public NotificationBroadcasterSupport(MBeanNotificationInfo ... info)

      使用有关可能发送的通知的信息构造 NotificationBroadcasterSupport。每个监听器都由发送通知的线程调用。此构造函数等效于 NotificationBroadcasterSupport(null, info)

      如果 info 数组不为空,则构造函数将其克隆为 info.clone() ,并且每次调用 getNotificationInfo() 都会返回一个新的克隆。

      参数:
      info - 一个数组,指示对于此 MBean 可能发送的每个通知,通知的 Java 类的名称和通知类型。可以为null,相当于一个空数组。
      自从:
      1.6
    • NotificationBroadcasterSupport

      public NotificationBroadcasterSupport(Executor  executor, MBeanNotificationInfo ... info)

      构造一个 NotificationBroadcasterSupport,其中包含有关可能发送的通知的信息,以及使用给定的 Executor 调用每个监听器的位置。

      调用 sendNotification 时,如果添加了空值 NotificationFilter isNotificationEnabled 为发送的通知返回 true,则选择一个监听器。对 NotificationFilter.isNotificationEnabled 的调用发生在调用 sendNotification 的线程中。然后,对于每个选定的监听器,使用调用 handleNotification 方法的命令调用 executor.execute

      如果 info 数组不为空,则构造函数将其克隆为 info.clone() ,并且每次调用 getNotificationInfo() 都会返回一个新的克隆。

      参数:
      executor - 方法 sendNotification 用于发送每个通知的执行程序。如果它为 null,调用 sendNotification 的线程将调用 handleNotification 方法本身。
      info - 一个数组,指示对于此 MBean 可能发送的每个通知,通知的 Java 类的名称和通知类型。可以为null,相当于一个空数组。
      自从:
      1.6
  • 方法详情