Java Reference
In-Depth Information
The NotificationBroadcaster interface
Figure 6.1 shows the UML diagram for the NotificationBroadcaster interface.
This section introduces the methods of the interface.
The interface contains methods for adding and removing notification listen-
ers. These methods allow objects to register as listeners for the notifications an
MBean can emit. Listeners provide a callback method that broadcasters invoke
in order to deliver a notification.
Notice in the addNotificationListener() method that one of the arguments
is the NotificationFilter class. This object is the filter mentioned previously,
and we discuss it in section 6.2.4. The last argument of this method is an Object
instance called the handback . This value is sent back to the listener when a notifi-
cation is delivered and should never be modified by the broadcaster. Both the fil-
ter and handback objects are optional and can be null.
The handback object can be used to provide a broadcaster with a context for
the listener. For example, take the case of internationalization. Assume an
MBean is sending out notifications that contain messages intended for human
users. In order to internationalize this message, the MBean would need a resource
bundle or language file to provide a translation. Each listener that registers for
the notification could provide its own resource bundle that allows the MBean to
Figure 6.1
UML diagram of the
NotificationBroadcaster interface
Search WWH ::




Custom Search