javax.management.monitor
Class Monitor

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport (src) 
      extended byjavax.management.monitor.Monitor
All Implemented Interfaces:
MBeanRegistration (src) , MonitorMBean (src) , NotificationBroadcaster (src) , NotificationEmitter (src)
Direct Known Subclasses:
CounterMonitor (src) , GaugeMonitor (src) , StringMonitor (src)

public abstract class Monitor
extends NotificationBroadcasterSupport (src)
implements MonitorMBean (src) , MBeanRegistration (src)

The monitor service.

Revisions:

20020319 Adrian Brock:


Field Summary
protected  int alreadyNotified
          Deprecated. use alreadyNotifieds[0]
protected  int[] alreadyNotifieds
          The errors that have already been notified.
protected static int capacityIncrement
          The amount by which arrays are incremented.
protected  java.lang.String dbgTag
          Deprecated. No replacement.
protected  int elementCount
          The number of valid elements in the arrays.
protected static int OBSERVED_ATTRIBUTE_ERROR_NOTIFIED
          An observed attribute error has been notified.
protected static int OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED
          An observed attribute type error has been notified.
protected static int OBSERVED_OBJECT_ERROR_NOTIFIED
          An observed object error has been notified.
protected static int RESET_FLAGS_ALREADY_NOTIFIED
          Used to reset errors in alreadyNotified.
protected static int RUNTIME_ERROR_NOTIFIED
          An observed attribute type error has been notified.
protected  MBeanServer (src) server
          The server this service is registered in.
 
Constructor Summary
Monitor()
           
 
Method Summary
 void addObservedObject(ObjectName (src)  object)
          Add the object name of the MBean monitored.
 boolean containsObservedObject(ObjectName (src)  object)
          Checks whether the object name is monitored.
 long getGranularityPeriod()
          Retrieves the granularity period in milliseconds.
 java.lang.String getObservedAttribute()
          Retrieves the name of the attribute monitored.
 ObjectName (src) getObservedObject()
          Retrieves the object name of the MBean monitored.
 ObjectName (src) [] getObservedObjects()
          Retrieves the object names of the MBeans monitored.
 boolean isActive()
          Tests whether this monitoring service is active.
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(java.lang.Boolean registrationDone)
          This method is called by the MBeanServer after registration takes place or when registration fails.
 void preDeregister()
          This method is called by the MBeanServer before deregistration takes place.
 ObjectName (src) preRegister(MBeanServer (src)  server, ObjectName (src)  objectName)
          This method is called by the MBeanServer before registration takes place.
 void removeObservedObject(ObjectName (src)  object)
          Remove the object name of the MBean monitored.
 void setGranularityPeriod(long period)
          Sets the granularity period in milliseconds.
 void setObservedAttribute(java.lang.String attribute)
          Sets the name of the attribute monitored.
 void setObservedObject(ObjectName (src)  object)
          Sets the object name of the MBean monitored.
abstract  void start()
          Starts the monitor.
abstract  void stop()
          Stops the monitor.
 java.lang.String toString()
           
 
Methods inherited from class javax.management.NotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

capacityIncrement

protected static final int capacityIncrement
The amount by which arrays are incremented.

See Also:
Constant Field Values (src)

RESET_FLAGS_ALREADY_NOTIFIED

protected static final int RESET_FLAGS_ALREADY_NOTIFIED
Used to reset errors in alreadyNotified.

See Also:
Constant Field Values (src)

RUNTIME_ERROR_NOTIFIED

protected static final int RUNTIME_ERROR_NOTIFIED
An observed attribute type error has been notified.

See Also:
Constant Field Values (src)

OBSERVED_OBJECT_ERROR_NOTIFIED

protected static final int OBSERVED_OBJECT_ERROR_NOTIFIED
An observed object error has been notified.

See Also:
Constant Field Values (src)

OBSERVED_ATTRIBUTE_ERROR_NOTIFIED

protected static final int OBSERVED_ATTRIBUTE_ERROR_NOTIFIED
An observed attribute error has been notified.

See Also:
Constant Field Values (src)

OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED

protected static final int OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED
An observed attribute type error has been notified.

See Also:
Constant Field Values (src)

elementCount

protected int elementCount
The number of valid elements in the arrays.


server

protected MBeanServer (src)  server
The server this service is registered in.


alreadyNotified

protected int alreadyNotified
Deprecated. use alreadyNotifieds[0]

The errors that have already been notified. REVIEW: Check


alreadyNotifieds

protected int[] alreadyNotifieds
The errors that have already been notified.


dbgTag

protected java.lang.String dbgTag
Deprecated. No replacement.

Constructor Detail

Monitor

public Monitor()
Method Detail

getGranularityPeriod

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

The monitoring takes place once per granularity period.

Specified by:
getGranularityPeriod in interface MonitorMBean (src)
Returns:
the granularity period.

getObservedAttribute

public java.lang.String getObservedAttribute()
Description copied from interface: MonitorMBean (src)
Retrieves the name of the attribute monitored.

Specified by:
getObservedAttribute in interface MonitorMBean (src)
Returns:
the attribute monitored.

getObservedObject

public ObjectName (src)  getObservedObject()
Description copied from interface: MonitorMBean (src)
Retrieves the object name of the MBean monitored.

Specified by:
getObservedObject in interface MonitorMBean (src)
Returns:
the object name.

getObservedObjects

public ObjectName (src) [] getObservedObjects()
Description copied from interface: MonitorMBean (src)
Retrieves the object names of the MBeans monitored.

Specified by:
getObservedObjects in interface MonitorMBean (src)
Returns:
the object names.

isActive

public boolean isActive()
Description copied from interface: MonitorMBean (src)
Tests whether this monitoring service is active.

Specified by:
isActive in interface MonitorMBean (src)
Returns:
true when the service is active, false otherwise.

setGranularityPeriod

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

The monitoring takes place once per granularity period.

The default value is 10 seconds.

Specified by:
setGranularityPeriod in interface MonitorMBean (src)
Parameters:
period - the granularity period.
Throws:
java.lang.IllegalArgumentException - when the period is not positive.

setObservedAttribute

public void setObservedAttribute(java.lang.String attribute)
                          throws java.lang.IllegalArgumentException
Description copied from interface: MonitorMBean (src)
Sets the name of the attribute monitored.

The default value is null.

Specified by:
setObservedAttribute in interface MonitorMBean (src)
Parameters:
attribute - the attribute monitored.
Throws:
java.lang.IllegalArgumentException - when the period is not positive.

setObservedObject

public void setObservedObject(ObjectName (src)  object)
                       throws java.lang.IllegalArgumentException
Description copied from interface: MonitorMBean (src)
Sets the object name of the MBean monitored.

The default value is null.

Specified by:
setObservedObject in interface MonitorMBean (src)
Parameters:
object - the object name.
Throws:
java.lang.IllegalArgumentException

addObservedObject

public void addObservedObject(ObjectName (src)  object)
                       throws java.lang.IllegalArgumentException
Description copied from interface: MonitorMBean (src)
Add the object name of the MBean monitored.

Specified by:
addObservedObject in interface MonitorMBean (src)
Parameters:
object - the object name.
Throws:
java.lang.IllegalArgumentException

removeObservedObject

public void removeObservedObject(ObjectName (src)  object)
Description copied from interface: MonitorMBean (src)
Remove the object name of the MBean monitored.

Specified by:
removeObservedObject in interface MonitorMBean (src)
Parameters:
object - the object name.

containsObservedObject

public boolean containsObservedObject(ObjectName (src)  object)
Description copied from interface: MonitorMBean (src)
Checks whether the object name is monitored.

Specified by:
containsObservedObject in interface MonitorMBean (src)
Parameters:
object - the object name.
Returns:
true when it is monitored.

start

public abstract void start()
Description copied from interface: MonitorMBean (src)
Starts the monitor.

Specified by:
start in interface MonitorMBean (src)

stop

public abstract void stop()
Description copied from interface: MonitorMBean (src)
Stops the monitor.

Specified by:
stop in interface MonitorMBean (src)

toString

public java.lang.String toString()

preRegister

public ObjectName (src)  preRegister(MBeanServer (src)  server,
                              ObjectName (src)  objectName)
                       throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before registration takes place. The MBean is passed a reference of the MBeanServer it is about to be registered with. The MBean must return the ObjectName it will be registered with. The MBeanServer can pass a suggested object depending upon how the MBean is registered.

The MBean can stop the registration by throwing an exception.The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preRegister in interface MBeanRegistration (src)
Returns:
the actual ObjectName to register this MBean with.
Throws:
java.lang.Exception - for any error, the MBean is not registered.

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after registration takes place or when registration fails.

Specified by:
postRegister in interface MBeanRegistration (src)
Parameters:
registrationDone - the MBeanServer passes true when the MBean was registered, false otherwise.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before deregistration takes place.

The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preDeregister in interface MBeanRegistration (src)
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after deregistration takes place.

Specified by:
postDeregister in interface MBeanRegistration (src)