On this page
Class Monitor
- All Implemented Interfaces:
MBeanRegistration
,MonitorMBean
,NotificationBroadcaster
,NotificationEmitter
- Direct Known Subclasses:
CounterMonitor
,GaugeMonitor
,StringMonitor
public abstract class Monitor extends NotificationBroadcasterSupport implements MonitorMBean, MBeanRegistration
- Since:
- 1.5
Field Summary
Modifier and Type | Field | Description |
---|---|---|
protected int |
alreadyNotified |
Deprecated.
|
protected int[] |
alreadyNotifieds |
Selected monitor errors that have already been notified.
|
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.
|
protected String |
dbgTag |
Deprecated.
No replacement.
|
protected int |
elementCount |
The number of valid components in the vector of observed objects.
|
protected static final int |
OBSERVED_ATTRIBUTE_ERROR_NOTIFIED |
Flag denoting that a notification has occurred after changing the observed attribute.
|
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.
|
protected static final int |
OBSERVED_OBJECT_ERROR_NOTIFIED |
Flag denoting that a notification has occurred after changing the observed object.
|
protected static final int |
RESET_FLAGS_ALREADY_NOTIFIED |
This flag is used to reset the alreadyNotifieds monitor attribute.
|
protected static final int |
RUNTIME_ERROR_NOTIFIED |
Flag denoting that a notification has occurred after changing the observed object or the observed attribute.
|
protected MBeanServer |
server |
Reference to the MBean server.
|
Constructor Summary
Constructor | Description |
---|---|
Monitor() |
Constructor for subclasses to call.
|
Method Summary
Modifier and Type | Method | Description |
---|---|---|
void |
addObservedObject |
Adds the specified object in the set of observed MBeans, if this object is not already present.
|
boolean |
containsObservedObject |
Tests whether the specified object is in the set of observed MBeans.
|
long |
getGranularityPeriod() |
Gets the granularity period (in milliseconds).
|
String |
getObservedAttribute() |
Gets the attribute being observed.
|
ObjectName |
getObservedObject() |
Deprecated.
As of JMX 1.2, replaced by
getObservedObjects()
|
ObjectName[] |
getObservedObjects() |
Returns an array containing the objects being observed.
|
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 |
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 |
Allows the monitor MBean to perform any operations it needs before being registered in the MBean server.
|
void |
removeObservedObject |
Removes the specified object from the set of observed MBeans.
|
void |
setGranularityPeriod |
Sets the granularity period (in milliseconds).
|
void |
setObservedAttribute |
Sets the attribute to observe.
|
void |
setObservedObject |
Deprecated.
As of JMX 1.2, replaced by
addObservedObject(javax.management.ObjectName)
|
abstract void |
start() |
Starts the monitor.
|
abstract void |
stop() |
Stops the monitor.
|
Methods declared in class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
Field Details
capacityIncrement
protected static final int capacityIncrement
- See Also:
elementCount
protected int elementCount
alreadyNotified
@Deprecated protected int alreadyNotified
alreadyNotifieds
[0].
alreadyNotifieds
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.
server
protected MBeanServer server
- See Also:
RESET_FLAGS_ALREADY_NOTIFIED
protected static final int RESET_FLAGS_ALREADY_NOTIFIED
alreadyNotifieds
monitor attribute.
- See Also:
OBSERVED_OBJECT_ERROR_NOTIFIED
protected static final int OBSERVED_OBJECT_ERROR_NOTIFIED
- See Also:
OBSERVED_ATTRIBUTE_ERROR_NOTIFIED
protected static final int OBSERVED_ATTRIBUTE_ERROR_NOTIFIED
- See Also:
OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED
protected static final int OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED
- See Also:
RUNTIME_ERROR_NOTIFIED
protected static final int RUNTIME_ERROR_NOTIFIED
- See Also:
dbgTag
@Deprecated protected String dbgTag
Constructor Details
Monitor
public Monitor()
Method Details
preRegister
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
Initializes the reference to the MBean server.
- Specified by:
preRegister
in interfaceMBeanRegistration
- 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
postRegister
public void postRegister(Boolean registrationDone)
Not used in this context.
- Specified by:
postRegister
in interfaceMBeanRegistration
- 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.
preDeregister
public void preDeregister() throws Exception
Stops the monitor.
- Specified by:
preDeregister
in interfaceMBeanRegistration
- Throws:
Exception
- if something goes wrong
postDeregister
public void postDeregister()
Not used in this context.
- Specified by:
postDeregister
in interfaceMBeanRegistration
start
public abstract void start()
- Specified by:
start
in interfaceMonitorMBean
stop
public abstract void stop()
- Specified by:
stop
in interfaceMonitorMBean
getObservedObject
@Deprecated public ObjectName getObservedObject()
getObservedObjects()
null
if there is no such object.
- Specified by:
getObservedObject
in interfaceMonitorMBean
- Returns:
- The object being observed.
- See Also:
setObservedObject
@Deprecated public void setObservedObject(ObjectName object) throws IllegalArgumentException
addObservedObject(javax.management.ObjectName)
- Specified by:
setObservedObject
in interfaceMonitorMBean
- Parameters:
object
- The object to observe.- Throws:
IllegalArgumentException
- The specified object is null.- See Also:
addObservedObject
public void addObservedObject(ObjectName object) throws IllegalArgumentException
- Specified by:
addObservedObject
in interfaceMonitorMBean
- Parameters:
object
- The object to observe.- Throws:
IllegalArgumentException
- The specified object is null.
removeObservedObject
public void removeObservedObject(ObjectName object)
- Specified by:
removeObservedObject
in interfaceMonitorMBean
- Parameters:
object
- The object to remove.
containsObservedObject
public boolean containsObservedObject(ObjectName object)
- Specified by:
containsObservedObject
in interfaceMonitorMBean
- Parameters:
object
- The object to check.- Returns:
true
if the specified object is present,false
otherwise.
getObservedObjects
public ObjectName[] getObservedObjects()
- Specified by:
getObservedObjects
in interfaceMonitorMBean
- Returns:
- The objects being observed.
getObservedAttribute
public String getObservedAttribute()
The observed attribute is not initialized by default (set to null).
- Specified by:
getObservedAttribute
in interfaceMonitorMBean
- Returns:
- The attribute being observed.
- See Also:
setObservedAttribute
public void setObservedAttribute(String attribute) throws IllegalArgumentException
The observed attribute is not initialized by default (set to null).
- Specified by:
setObservedAttribute
in interfaceMonitorMBean
- Parameters:
attribute
- The attribute to observe.- Throws:
IllegalArgumentException
- The specified attribute is null.- See Also:
getGranularityPeriod
public long getGranularityPeriod()
The default value of the granularity period is 10 seconds.
- Specified by:
getGranularityPeriod
in interfaceMonitorMBean
- Returns:
- The granularity period value.
- See Also:
setGranularityPeriod
public void setGranularityPeriod(long period) throws IllegalArgumentException
The default value of the granularity period is 10 seconds.
- Specified by:
setGranularityPeriod
in interfaceMonitorMBean
- Parameters:
period
- The granularity period value.- Throws:
IllegalArgumentException
- The granularity period is less than or equal to zero.- See Also:
isActive
public boolean isActive()
start
method is called. It becomes inactive when the stop
method is called.
- Specified by:
isActive
in interfaceMonitorMBean
- Returns:
true
if the monitor MBean is active,false
otherwise.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.management/javax/management/monitor/Monitor.html
alreadyNotifieds
[0].