Java Reference
In-Depth Information
The AttributeChangeNotification class extends the class Notification , and
therefore inherits its class members for the notification message, timestamp, and
so forth. However, it provides four additional fields that provide the receiver
with all the information about an MBean attribute change. Table 6.3 lists the
four additional class member variables by their access methods.
Table 6.3
The additional class members from the AttributeChangeNotification class
Class member
Purpose
Returns the name of the attribute that changed as a String object
getAttributeName()
getAttributeType()
Returns the class type of the attribute that changed as a String object
getNewValue()
Returns an Object instance containing the new value of the attribute
that changed
Returns the Object instance containing the old value of the attribute
that changed
getOldValue()
All AttributeChangeNotification notifications use the notification type jmx.at-
tribute.change . This type is defined by the public static class member variable
AttributeChangeNotification.ATTRIBUTE_CHANGE . This notification class pro-
vides a single constructor in which you pass all the arguments needed to popu-
late the notification shown here:
public AttributeChangeNotification( java.lang.Object source,
long sequenceNumber, long timeStamp, java.lang.String msg,
java.lang.String attributeName, java.lang.String attributeType,
java.lang.Object oldValue, java.lang.Object newValue )
With this new notification class comes a new concept surrounding filtering. All
attribute change notification types are jmx. attribute .change , so you need a dif-
ferent method of filtering. This is the case because even though many notifica-
tions of the same type may be received, they could be encapsulating different
attributes that have been altered. Filtering is needed because you may not want
to receive all attribute-change events from an MBean.
6.4.1
Filtering attribute change notifications
As with any notification, listeners should be able to filter out attribute change noti-
fications that are not desired. However, all AttributeChangeNotification notifica-
tions have the same type. Using the NotificationFilterSupport class examined
earlier won't help, because it filters based on notification type. Therefore, if a lis-
tener only wanted to receive a notification for a specific attribute, the filter would
need to examine the contents of the attribute notifications, not the type.
Search WWH ::




Custom Search