- java.lang.Object
- 
- javax.management.NotificationBroadcasterSupport
- 
- javax.management.monitor.Monitor
 
 
- 
- All Implemented Interfaces:
- MBeanRegistration,- MonitorMBean,- NotificationBroadcaster,- NotificationEmitter
 - Direct Known Subclasses:
- CounterMonitor,- GaugeMonitor,- StringMonitor
 
 public abstract class Monitor extends NotificationBroadcasterSupport implements MonitorMBean, MBeanRegistration 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.- Since:
- 1.5
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected intalreadyNotifiedDeprecated.equivalent toalreadyNotifieds[0].protected int[]alreadyNotifiedsSelected monitor errors that have already been notified.protected static intcapacityIncrementThe amount by which the capacity of the monitor arrays are automatically incremented when their size becomes greater than their capacity.protected StringdbgTagDeprecated.No replacement.protected intelementCountThe number of valid components in the vector of observed objects.protected static intOBSERVED_ATTRIBUTE_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing the observed attribute.protected static intOBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing the observed object or the observed attribute.protected static intOBSERVED_OBJECT_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing the observed object.protected static intRESET_FLAGS_ALREADY_NOTIFIEDThis flag is used to reset thealreadyNotifiedsmonitor attribute.protected static intRUNTIME_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing the observed object or the observed attribute.protected MBeanServerserverReference to the MBean server.
 - 
Constructor SummaryConstructors Constructor Description Monitor()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddObservedObject(ObjectName object)Adds the specified object in the set of observed MBeans, if this object is not already present.booleancontainsObservedObject(ObjectName object)Tests whether the specified object is in the set of observed MBeans.longgetGranularityPeriod()Gets the granularity period (in milliseconds).StringgetObservedAttribute()Gets the attribute being observed.ObjectNamegetObservedObject()Deprecated.As of JMX 1.2, replaced bygetObservedObjects()ObjectName[]getObservedObjects()Returns an array containing the objects being observed.booleanisActive()Tests whether the monitor MBean is active.voidpostDeregister()Allows the monitor MBean to perform any operations needed after having been unregistered by the MBean server.voidpostRegister(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.voidpreDeregister()Allows the monitor MBean to perform any operations it needs before being unregistered by the MBean server.ObjectNamepreRegister(MBeanServer server, ObjectName name)Allows the monitor MBean to perform any operations it needs before being registered in the MBean server.voidremoveObservedObject(ObjectName object)Removes the specified object from the set of observed MBeans.voidsetGranularityPeriod(long period)Sets the granularity period (in milliseconds).voidsetObservedAttribute(String attribute)Sets the attribute to observe.voidsetObservedObject(ObjectName object)Deprecated.As of JMX 1.2, replaced byaddObservedObject(javax.management.ObjectName)abstract voidstart()Starts the monitor.abstract voidstop()Stops the monitor.- 
Methods declared in class javax.management.NotificationBroadcasterSupportaddNotificationListener, handleNotification, sendNotification
 - 
Methods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods declared in interface javax.management.NotificationBroadcastergetNotificationInfo, removeNotificationListener
 - 
Methods declared in interface javax.management.NotificationEmitterremoveNotificationListener
 
- 
 
- 
- 
- 
Field Detail- 
capacityIncrementprotected 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.- See Also:
- Constant Field Values
 
 - 
elementCountprotected int elementCount The number of valid components in the vector of observed objects.
 - 
alreadyNotified@Deprecated protected int alreadyNotified Deprecated.equivalent toalreadyNotifieds[0].Monitor errors that have already been notified.
 - 
alreadyNotifiedsprotected 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_NOTIFIEDetc, indicating whether the corresponding notification has already been sent for the MBean being monitored.
 - 
serverprotected 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.
 - 
RESET_FLAGS_ALREADY_NOTIFIEDprotected static final int RESET_FLAGS_ALREADY_NOTIFIED This flag is used to reset thealreadyNotifiedsmonitor attribute.- See Also:
- Constant Field Values
 
 - 
OBSERVED_OBJECT_ERROR_NOTIFIEDprotected 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.- See Also:
- Constant Field Values
 
 - 
OBSERVED_ATTRIBUTE_ERROR_NOTIFIEDprotected 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.- See Also:
- Constant Field Values
 
 - 
OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIEDprotected 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.- See Also:
- Constant Field Values
 
 - 
RUNTIME_ERROR_NOTIFIEDprotected 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.- See Also:
- Constant Field Values
 
 - 
dbgTag@Deprecated protected String dbgTag Deprecated.No replacement.This field is retained for compatibility but should not be referenced.
 
- 
 - 
Method Detail- 
preRegisterpublic ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception Allows the monitor MBean to perform any operations it needs before being registered in the MBean server.Initializes the reference to the MBean server. - Specified by:
- preRegisterin interface- MBeanRegistration
- 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- if something goes wrong
 
 - 
postRegisterpublic 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. - Specified by:
- postRegisterin interface- MBeanRegistration
- 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.
 
 - 
preDeregisterpublic void preDeregister() throws ExceptionAllows the monitor MBean to perform any operations it needs before being unregistered by the MBean server.Stops the monitor. - Specified by:
- preDeregisterin interface- MBeanRegistration
- Throws:
- Exception- if something goes wrong
 
 - 
postDeregisterpublic void postDeregister() Allows the monitor MBean to perform any operations needed after having been unregistered by the MBean server.Not used in this context. - Specified by:
- postDeregisterin interface- MBeanRegistration
 
 - 
startpublic abstract void start() Starts the monitor.- Specified by:
- startin interface- MonitorMBean
 
 - 
stoppublic abstract void stop() Stops the monitor.- Specified by:
- stopin interface- MonitorMBean
 
 - 
getObservedObject@Deprecated public ObjectName getObservedObject() Deprecated.As of JMX 1.2, replaced bygetObservedObjects()Returns the object name of the first object in the set of observed MBeans, ornullif there is no such object.- Specified by:
- getObservedObjectin interface- MonitorMBean
- Returns:
- The object being observed.
- See Also:
- setObservedObject(ObjectName)
 
 - 
setObservedObject@Deprecated public void setObservedObject(ObjectName object) throws IllegalArgumentException Deprecated.As of JMX 1.2, replaced byaddObservedObject(javax.management.ObjectName)Removes all objects from the set of observed objects, and then adds the specified object.- Specified by:
- setObservedObjectin interface- MonitorMBean
- Parameters:
- object- The object to observe.
- Throws:
- IllegalArgumentException- The specified object is null.
- See Also:
- getObservedObject()
 
 - 
addObservedObjectpublic void addObservedObject(ObjectName object) throws IllegalArgumentException Adds the specified object in the set of observed MBeans, if this object is not already present.- Specified by:
- addObservedObjectin interface- MonitorMBean
- Parameters:
- object- The object to observe.
- Throws:
- IllegalArgumentException- The specified object is null.
 
 - 
removeObservedObjectpublic void removeObservedObject(ObjectName object) Removes the specified object from the set of observed MBeans.- Specified by:
- removeObservedObjectin interface- MonitorMBean
- Parameters:
- object- The object to remove.
 
 - 
containsObservedObjectpublic boolean containsObservedObject(ObjectName object) Tests whether the specified object is in the set of observed MBeans.- Specified by:
- containsObservedObjectin interface- MonitorMBean
- Parameters:
- object- The object to check.
- Returns:
- trueif the specified object is present,- falseotherwise.
 
 - 
getObservedObjectspublic ObjectName[] getObservedObjects() Returns an array containing the objects being observed.- Specified by:
- getObservedObjectsin interface- MonitorMBean
- Returns:
- The objects being observed.
 
 - 
getObservedAttributepublic String getObservedAttribute() Gets the attribute being observed.
 The observed attribute is not initialized by default (set to null).- Specified by:
- getObservedAttributein interface- MonitorMBean
- Returns:
- The attribute being observed.
- See Also:
- setObservedAttribute(java.lang.String)
 
 - 
setObservedAttributepublic void setObservedAttribute(String attribute) throws IllegalArgumentException Sets the attribute to observe.
 The observed attribute is not initialized by default (set to null).- Specified by:
- setObservedAttributein interface- MonitorMBean
- Parameters:
- attribute- The attribute to observe.
- Throws:
- IllegalArgumentException- The specified attribute is null.
- See Also:
- getObservedAttribute()
 
 - 
getGranularityPeriodpublic long getGranularityPeriod() Gets the granularity period (in milliseconds).
 The default value of the granularity period is 10 seconds.- Specified by:
- getGranularityPeriodin interface- MonitorMBean
- Returns:
- The granularity period value.
- See Also:
- setGranularityPeriod(long)
 
 - 
setGranularityPeriodpublic void setGranularityPeriod(long period) throws IllegalArgumentExceptionSets the granularity period (in milliseconds).
 The default value of the granularity period is 10 seconds.- Specified by:
- setGranularityPeriodin interface- MonitorMBean
- Parameters:
- period- The granularity period value.
- Throws:
- IllegalArgumentException- The granularity period is less than or equal to zero.
- See Also:
- getGranularityPeriod()
 
 - 
isActivepublic boolean isActive() Tests whether the monitor MBean is active. A monitor MBean is marked active when thestartmethod is called. It becomes inactive when thestopmethod is called.- Specified by:
- isActivein interface- MonitorMBean
- Returns:
- trueif the monitor MBean is active,- falseotherwise.
 
 
- 
 
-