public abstract class

Monitor

extends NotificationBroadcasterSupport
implements MBeanRegistration MonitorMBean
java.lang.Object
   ↳ javax.management.NotificationBroadcasterSupport
     ↳ javax.management.monitor.Monitor
Known Direct Subclasses

Class Overview

Defines the part common to all monitor MBeans. A monitor MBean monitors values of an attribute common to a set of observed MBeans. 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.

Summary

Constants
int OBSERVED_ATTRIBUTE_ERROR_NOTIFIED Flag denoting that a notification has occurred after changing the observed attribute.
int OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED Flag denoting that a notification has occurred after changing the observed object or the observed attribute.
int OBSERVED_OBJECT_ERROR_NOTIFIED Flag denoting that a notification has occurred after changing the observed object.
int RESET_FLAGS_ALREADY_NOTIFIED This flag is used to reset the alreadyNotifieds monitor attribute.
int RUNTIME_ERROR_NOTIFIED Flag denoting that a notification has occurred after changing the observed object or the observed attribute.
int capacityIncrement The amount by which the capacity of the monitor arrays are automatically incremented when their size becomes greater than their capacity.
Fields
protected int alreadyNotified This field is deprecated. equivalent to alreadyNotifieds[0].
protected int[] alreadyNotifieds

Selected monitor errors that have already been notified.

protected String dbgTag This field is deprecated. No replacement.
protected int elementCount The number of valid components in the vector of observed objects.
protected MBeanServer server Reference to the MBean server.
Public Constructors
Monitor()
Public Methods
synchronized void addObservedObject(ObjectName object)
Adds the specified object in the set of observed MBeans, if this object is not already present.
synchronized boolean containsObservedObject(ObjectName object)
Tests whether the specified object is in the set of observed MBeans.
synchronized long getGranularityPeriod()
Gets the granularity period (in milliseconds).
synchronized String getObservedAttribute()
Gets the attribute being observed.
synchronized ObjectName getObservedObject()
This method is deprecated. As of JMX 1.2, replaced by getObservedObjects()
synchronized ObjectName[] getObservedObjects()
Returns an array containing the objects being observed.
synchronized boolean isActive()
Tests whether the monitor MBean is active.
void postDeregister()
Allows the monitor MBean to perform any operations needed after having been unregistered by the MBean server.
void postRegister(Boolean registrationDone)
Allows the monitor MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
void preDeregister()
Allows the monitor MBean to perform any operations it needs before being unregistered by the MBean server.
ObjectName preRegister(MBeanServer server, ObjectName name)
Allows the monitor MBean to perform any operations it needs before being registered in the MBean server.
synchronized void removeObservedObject(ObjectName object)
Removes the specified object from the set of observed MBeans.
synchronized void setGranularityPeriod(long period)
Sets the granularity period (in milliseconds).
void setObservedAttribute(String attribute)
Sets the attribute to observe.
synchronized void setObservedObject(ObjectName object)
This method is deprecated. As of JMX 1.2, replaced by addObservedObject(ObjectName)
abstract void start()
Starts the monitor.
abstract void stop()
Stops the monitor.
[Expand]
Inherited Methods
From class javax.management.NotificationBroadcasterSupport
From class java.lang.Object
From interface javax.management.MBeanRegistration
From interface javax.management.NotificationBroadcaster
From interface javax.management.NotificationEmitter
From interface javax.management.monitor.MonitorMBean

Constants

protected static final int OBSERVED_ATTRIBUTE_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed attribute. This flag is used to check that the new observed attribute belongs to the observed object at the time of the first notification.

Constant Value: 2 (0x00000002)

protected static final int OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed object or the observed attribute. This flag is used to check that the observed attribute type is correct (depending on the monitor in use) at the time of the first notification.

Constant Value: 4 (0x00000004)

protected static final int OBSERVED_OBJECT_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed object. This flag is used to check that the new observed object is registered in the MBean server at the time of the first notification.

Constant Value: 1 (0x00000001)

protected static final int RESET_FLAGS_ALREADY_NOTIFIED

This flag is used to reset the alreadyNotifieds monitor attribute.

Constant Value: 0 (0x00000000)

protected static final int RUNTIME_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed object or the observed attribute. This flag is used to notify any exception (except the cases described above) when trying to get the value of the observed attribute at the time of the first notification.

Constant Value: 8 (0x00000008)

protected static final int capacityIncrement

The amount by which the capacity of the monitor arrays are automatically incremented when their size becomes greater than their capacity.

Constant Value: 16 (0x00000010)

Fields

protected int alreadyNotified

This field is deprecated.
equivalent to alreadyNotifieds[0].

Monitor errors that have already been notified.

protected int[] alreadyNotifieds

Selected monitor errors that have already been notified.

Each element in this array corresponds to an observed object in the vector. It contains a bit mask of the flags OBSERVED_OBJECT_ERROR_NOTIFIED etc, indicating whether the corresponding notification has already been sent for the MBean being monitored.

protected String dbgTag

This field is deprecated.
No replacement.

This field is retained for compatibility but should not be referenced.

protected int elementCount

The number of valid components in the vector of observed objects.

protected MBeanServer server

Reference to the MBean server. This reference is null when the monitor MBean is not registered in an MBean server. This reference is initialized before the monitor MBean is registered in the MBean server.

Public Constructors

public Monitor ()

Public Methods

public synchronized void addObservedObject (ObjectName object)

Adds the specified object in the set of observed MBeans, if this object is not already present.

Parameters
object The object to observe.
Throws
IllegalArgumentException The specified object is null.

public synchronized boolean containsObservedObject (ObjectName object)

Tests whether the specified object is in the set of observed MBeans.

Parameters
object The object to check.
Returns
  • true if the specified object is present, false otherwise.

public synchronized long getGranularityPeriod ()

Gets the granularity period (in milliseconds).
The default value of the granularity period is 10 seconds.

Returns
  • The granularity period value.

public synchronized String getObservedAttribute ()

Gets the attribute being observed.
The observed attribute is not initialized by default (set to null).

Returns
  • The attribute being observed.

public synchronized ObjectName getObservedObject ()

This method is deprecated.
As of JMX 1.2, replaced by getObservedObjects()

Returns the object name of the first object in the set of observed MBeans, or null if there is no such object.

Returns
  • The object being observed.

public synchronized ObjectName[] getObservedObjects ()

Returns an array containing the objects being observed.

Returns
  • The objects being observed.

public synchronized boolean isActive ()

Tests whether the monitor MBean is active. A monitor MBean is marked active when the start method is called. It becomes inactive when the stop method is called.

Returns
  • true if the monitor MBean is active, false otherwise.

public void postDeregister ()

Allows the monitor MBean to perform any operations needed after having been unregistered by the MBean server.

Not used in this context.

public void postRegister (Boolean registrationDone)

Allows the monitor MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

Not used in this context.

Parameters
registrationDone Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.

public void preDeregister ()

Allows the monitor MBean to perform any operations it needs before being unregistered by the MBean server.

Stops the monitor.

Throws
Exception

public ObjectName preRegister (MBeanServer server, ObjectName name)

Allows the monitor MBean to perform any operations it needs before being registered in the MBean server.

Initializes the reference to the MBean server.

Parameters
server The MBean server in which the monitor MBean will be registered.
name The object name of the monitor MBean.
Returns
  • The name of the monitor MBean registered.
Throws
Exception

public synchronized void removeObservedObject (ObjectName object)

Removes the specified object from the set of observed MBeans.

Parameters
object The object to remove.

public synchronized void setGranularityPeriod (long period)

Sets the granularity period (in milliseconds).
The default value of the granularity period is 10 seconds.

Parameters
period The granularity period value.
Throws
IllegalArgumentException The granularity period is less than or equal to zero.

public void setObservedAttribute (String attribute)

Sets the attribute to observe.
The observed attribute is not initialized by default (set to null).

Parameters
attribute The attribute to observe.
Throws
IllegalArgumentException The specified attribute is null.

public synchronized void setObservedObject (ObjectName object)

This method is deprecated.
As of JMX 1.2, replaced by addObservedObject(ObjectName)

Removes all objects from the set of observed objects, and then adds the specified object.

Parameters
object The object to observe.
Throws
IllegalArgumentException The specified object is null.

public abstract void start ()

Starts the monitor.

public abstract void stop ()

Stops the monitor.