Java Reference
In-Depth Information
forward. Table 12.2 lists its available methods. Notice that the table leaves out
the methods implemented from the MBeanRegistration interface.
Table 12.2 The methods defined by the javax.management.monitor.Monitor class. This
class is the base class for all JMX monitor MBeans.
Method
Description
Returns the observation interval of this monitor.
long getGranularityPeriod()
Returns the name of the observed attribute.
String getObservedAttribute()
Returns the object name of the observed MBean.
ObjectName getObservedObject()
Determines if this monitor has been started.
boolean isActive()
Sets the observation interval of this monitor.
void setGranularityPeriod( long
period )
Sets the name of the attribute that will be monitored
from the given MBean (set in the next method).
void setObservedAttribute(
String name )
Sets the MBean that contains an attribute to observe.
Only the object name of the MBean is needed; the
monitor will interact with the MBean server to get the
attribute value when set.
void setObservedObject( Object-
Name name )
Starts observation of the set attribute.
abstract start()
Stops observation of the set attribute.
abstract stop()
All these methods are declared in the javax.management.monitor.MonitorMBean
interface. Because this class implements its own MBean interface, it would be a
Standard MBean if it were not an abstract class. (For more information about
Standard MBeans, look back at chapter 4.)
Notice that two of the methods are undefined (declared abstract): stop() and
start() . These two methods are implemented by subclasses, allowing each sub-
class to determine how the MBean monitors its observed value. As you might
expect, these methods correspond to starting and stopping the monitor.
We should highlight two methods from this class: setObservedObject() and
setObservedAttribute() . The first method tells the monitor which MBean in the
MBean server to observe. You need only pass it an object nameā€”it will use this
object name value, combined with the attribute name set by the setObservedAt-
tribute() method, to find the value of an MBean attribute. It does so at every
monitoring interval (granularity period).
Also note that each monitor subclass provided by JMX monitors an attribute
of a particular type, such as String or Double . However, the monitor MBeans do
Search WWH ::




Custom Search