javax.management.monitor
Class Monitor

java.lang.Object
  |
  +--javax.management.NotificationBroadcasterSupport
        |
        +--javax.management.monitor.Monitor
All Implemented Interfaces:
MBeanRegistration, MonitorMBean, NotificationBroadcaster
Direct Known Subclasses:
CounterMonitor, GaugeMonitor, StringMonitor

public abstract class Monitor
extends NotificationBroadcasterSupport
implements MonitorMBean, MBeanRegistration

Defines the common part to all monitor MBeans. A monitor MBean monitors values of an attribute in an observed MBean. The observed attribute is monitored at intervals specified by the granularity period. A gauge value (derived gauge) is derived from the values of the observed attribute.

Author:
Young Yang

Constructor Summary
Monitor()
           
 
Method Summary
protected  void _start()
           
protected  void _stop()
           
protected abstract  void doMonitor(java.lang.Object value)
           
 long getGranularityPeriod()
          Gets the granularity period (in milliseconds).
 java.lang.String getObservedAttribute()
          Gets the attribute being observed.
 ObjectName getObservedObject()
          Gets the object name of the object being observed.
 boolean isActive()
          Tests if the monitor MBean is active.
 void postDeregister()
          Allows the MBean to perform any operations needed after having been de-registered in the MBean server.
 void postRegister(java.lang.Boolean value)
          Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
 void preDeregister()
          Allows the MBean to perform any operations it needs before being de-registered by the MBean server.
 ObjectName preRegister(MBeanServer mbeanserver, ObjectName objectname)
          Allows the MBean to perform any operations it needs before being registered in the MBean server.
protected  void sendNotification(java.lang.String type, long timeStamp, java.lang.String message, java.lang.Object derivedValue, java.lang.Object trigger)
           
 void setGranularityPeriod(long period)
          Sets the granularity period (in milliseconds).
 void setObservedAttribute(java.lang.String attribute)
          Sets the attribute to observe.
 void setObservedObject(ObjectName objectname)
          Sets the object to observe identified by its object name.
abstract  void start()
           
abstract  void stop()
           
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Monitor

public Monitor()
Method Detail

preRegister

public ObjectName preRegister(MBeanServer mbeanserver,
                              ObjectName objectname)
                       throws java.lang.Exception
Description copied from interface: MBeanRegistration
Allows the MBean to perform any operations it needs before being registered in the MBean server. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBean server.

Specified by:
preRegister in interface MBeanRegistration
Parameters:
mbeanserver - The MBean server in which the MBean will be registered.
objectname - The object name of the MBean.
Returns:
The name of the MBean registered.
Throws:
java.lang.Exception - This exception should be caught by the MBean server and re-thrown as an MBeanRegistrationException.

postRegister

public void postRegister(java.lang.Boolean value)
Description copied from interface: MBeanRegistration
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

Specified by:
postRegister in interface MBeanRegistration
Parameters:
value - Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Description copied from interface: MBeanRegistration
Allows the MBean to perform any operations it needs before being de-registered by the MBean server.

Specified by:
preDeregister in interface MBeanRegistration
Throws:
java.lang.Exception - This exception should be caught by the MBean server and re-thrown as an MBeanRegistrationException.

postDeregister

public void postDeregister()
Description copied from interface: MBeanRegistration
Allows the MBean to perform any operations needed after having been de-registered in the MBean server.

Specified by:
postDeregister in interface MBeanRegistration

getObservedObject

public ObjectName getObservedObject()
Description copied from interface: MonitorMBean
Gets the object name of the object being observed.

Specified by:
getObservedObject in interface MonitorMBean
Returns:
The object being observed.

setObservedObject

public void setObservedObject(ObjectName objectname)
                       throws java.lang.IllegalArgumentException
Description copied from interface: MonitorMBean
Sets the object to observe identified by its object name.

Specified by:
setObservedObject in interface MonitorMBean
Parameters:
objectname - The object to observe.
java.lang.IllegalArgumentException

getObservedAttribute

public java.lang.String getObservedAttribute()
Description copied from interface: MonitorMBean
Gets the attribute being observed.

Specified by:
getObservedAttribute in interface MonitorMBean
Returns:
The attribute being observed.

setObservedAttribute

public void setObservedAttribute(java.lang.String attribute)
                          throws java.lang.IllegalArgumentException
Description copied from interface: MonitorMBean
Sets the attribute to observe.

Specified by:
setObservedAttribute in interface MonitorMBean
Parameters:
attribute - The attribute to observe.
java.lang.IllegalArgumentException

getGranularityPeriod

public long getGranularityPeriod()
Description copied from interface: MonitorMBean
Gets the granularity period (in milliseconds).

Specified by:
getGranularityPeriod in interface MonitorMBean
Returns:
The granularity period.

setGranularityPeriod

public void setGranularityPeriod(long period)
                          throws java.lang.IllegalArgumentException
Description copied from interface: MonitorMBean
Sets the granularity period (in milliseconds).

Specified by:
setGranularityPeriod in interface MonitorMBean
Parameters:
period - The granularity period.
Throws:
java.lang.IllegalArgumentException - The granularity period is less than or equal to zero.

isActive

public boolean isActive()
Description copied from interface: MonitorMBean
Tests if the monitor MBean is active.

Specified by:
isActive in interface MonitorMBean
Returns:
true if the monitor MBean is active, false otherwise.

start

public abstract void start()

stop

public abstract void stop()

sendNotification

protected void sendNotification(java.lang.String type,
                                long timeStamp,
                                java.lang.String message,
                                java.lang.Object derivedValue,
                                java.lang.Object trigger)

_start

protected void _start()

_stop

protected void _stop()

doMonitor

protected abstract void doMonitor(java.lang.Object value)