Java Reference
In-Depth Information
not validate the type of the attribute, only the type of the value returned from
the
getAttribute()
method of the MBean server. In essence, this process lets
you monitor an attribute whose value type is determined by its getter method
(and possibly is different from the attribute's declared type).
The MonitorNotification class
Now let's examine the notification class used by all monitors:
javax.manage-
ment.monitor.MonitorNotification
. This section will describe the notification
class and some of the common notification types it contains. Sections discussing
a specific monitor MBean will add any further notification types as they pertain
to the particular monitor MBean. All of the notification types are presented as
class member variables in the common notification class, but we will cover each
type only as we need to. If you need to refresh your knowledge of the
JMX
notifi-
cation mechanism, please look back at chapter 6.
The
MonitorNotification
class extends the basic
javax.management.Notifi-
cation
class and therefore inherits the basic notification methods. In addition, it
defines four more methods:
■
public Object getDerivedGauge()
—Returns the value computed from the
monitor's last observation from the observed MBean attribute
■
public String getObservedAttribute()
—Returns the name of the observed
MBean attribute
■
public ObjectName getObservedObject()
—Returns the object name of the
observed MBean
■
public Object getTrigger()
—Returns the value (of the observed attribute)
that triggered this notification to be sent
Remember that instances of this class are sent from monitors based on certain
observed events (which are configured in the specific monitor)—that is why these
methods are declared in this class. These methods give the listener much of the
information it needs to make informed decisions. The last piece of information a
listener would need from a notification is its notification type.
Recall that a notification type is a dot-separated
String
value that indicates the
purpose of a notification. Each monitor MBean uses its own specific notification
types, but the
MonitorNotification
class provides four types that are shared across
all monitor MBeans. The
MonitorNotification
class also declares some public
static final class members to denote the type values. Table 12.3 lists the types,
along with their class members and short descriptions of when they should occur.