- java.lang.Object
-
- javax.management.modelmbean.RequiredModelMBean
-
- All Implemented Interfaces:
- DynamicMBean, MBeanRegistration, ModelMBean, ModelMBeanNotificationBroadcaster, NotificationBroadcaster, NotificationEmitter, PersistentMBean
public class RequiredModelMBean extends Object implements ModelMBean, MBeanRegistration, NotificationEmitter
This class is the implementation of a ModelMBean. An appropriate implementation of a ModelMBean must be shipped with every JMX Agent and the class must be named RequiredModelMBean.Java resources wishing to be manageable instantiate the RequiredModelMBean using the MBeanServer's createMBean method. The resource then sets the MBeanInfo and Descriptors for the RequiredModelMBean instance. The attributes and operations exposed via the ModelMBeanInfo for the ModelMBean are accessible from MBeans, connectors/adaptors like other MBeans. Through the Descriptors, values and methods in the managed application can be defined and mapped to attributes and operations of the ModelMBean. This mapping can be defined in an XML formatted file or dynamically and programmatically at runtime.
Every RequiredModelMBean which is instantiated in the MBeanServer becomes manageable:
its attributes and operations become remotely accessible through the connectors/adaptors connected to that MBeanServer.A Java object cannot be registered in the MBeanServer unless it is a JMX compliant MBean. By instantiating a RequiredModelMBean, resources are guaranteed that the MBean is valid. MBeanException and RuntimeOperationsException must be thrown on every public method. This allows for wrapping exceptions from distributed communications (RMI, EJB, etc.)
- Since:
- 1.5
-
-
Constructor Summary
Constructors Constructor and Description RequiredModelMBean()
Constructs anRequiredModelMBean
with an empty ModelMBeanInfo.RequiredModelMBean(ModelMBeanInfo mbi)
Constructs a RequiredModelMBean object using ModelMBeanInfo passed in.
-
Method Summary
Methods Modifier and Type Method and Description void
addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback)
Registers an object which implements the NotificationListener interface as a listener.void
addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
Registers an object which implements the NotificationListener interface as a listener.Object
getAttribute(String attrName)
Returns the value of a specific attribute defined for this ModelMBean.AttributeList
getAttributes(String[] attrNames)
Returns the values of several attributes in the ModelMBean.protected ClassLoaderRepository
getClassLoaderRepository()
Return the Class Loader Repository used to perform class loading.MBeanInfo
getMBeanInfo()
Returns the attributes, operations, constructors and notifications that this RequiredModelMBean exposes for management.MBeanNotificationInfo[]
getNotificationInfo()
Returns the array of Notifications always generated by the RequiredModelMBean.Object
invoke(String opName, Object[] opArgs, String[] sig)
Invokes a method on or through a RequiredModelMBean and returns the result of the method execution.void
load()
Instantiates this MBean instance with the data found for the MBean in the persistent store.void
postDeregister()
Allows the MBean to perform any operations needed after having been unregistered in the MBean server.void
postRegister(Boolean registrationDone)
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 unregistered by the MBean server.ObjectName
preRegister(MBeanServer server, ObjectName name)
Allows the MBean to perform any operations it needs before being registered in the MBean server.void
removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName)
Removes a listener for attributeChangeNotifications from the RequiredModelMBean.void
removeNotificationListener(NotificationListener listener)
Removes a listener for Notifications from the RequiredModelMBean.void
removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
Removes a listener from this MBean.void
sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal)
Sends an attributeChangeNotification which contains the old value and new value for the attribute to the registered AttributeChangeNotification listeners on the ModelMBean.void
sendAttributeChangeNotification(AttributeChangeNotification ntfyObj)
Sends an attributeChangeNotification which is passed in to the registered attributeChangeNotification listeners on the ModelMBean.void
sendNotification(Notification ntfyObj)
Sends a Notification which is passed in to the registered Notification listeners on the ModelMBean as a jmx.modelmbean.generic notification.void
sendNotification(String ntfyText)
Sends a Notification which contains the text string that is passed in to the registered Notification listeners on the ModelMBean.void
setAttribute(Attribute attribute)
Sets the value of a specific attribute of a named ModelMBean.AttributeList
setAttributes(AttributeList attributes)
Sets the values of an array of attributes of this ModelMBean.void
setManagedResource(Object mr, String mr_type)
Sets the instance handle of the object against which to execute all methods in this ModelMBean management interface (MBeanInfo and Descriptors).void
setModelMBeanInfo(ModelMBeanInfo mbi)
Initializes a ModelMBean object using ModelMBeanInfo passed in.void
store()
Captures the current state of this MBean instance and writes it out to the persistent store.
-
-
-
Constructor Detail
-
RequiredModelMBean
public RequiredModelMBean() throws MBeanException, RuntimeOperationsException
Constructs anRequiredModelMBean
with an empty ModelMBeanInfo.The RequiredModelMBean's MBeanInfo and Descriptors can be customized using the
setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)
method. After the RequiredModelMBean's MBeanInfo and Descriptors are customized, the RequiredModelMBean can be registered with the MBeanServer.- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps aRuntimeException
during the construction of the object.
-
RequiredModelMBean
public RequiredModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
Constructs a RequiredModelMBean object using ModelMBeanInfo passed in. As long as the RequiredModelMBean is not registered with the MBeanServer yet, the RequiredModelMBean's MBeanInfo and Descriptors can be customized using thesetModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)
method. After the RequiredModelMBean's MBeanInfo and Descriptors are customized, the RequiredModelMBean can be registered with the MBeanServer.- Parameters:
mbi
- The ModelMBeanInfo object to be used by the RequiredModelMBean. The given ModelMBeanInfo is cloned and modified as specified bysetModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)
- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps an {link java.lang.IllegalArgumentException}: The MBeanInfo passed in parameter is null.
-
-
Method Detail
-
setModelMBeanInfo
public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
Initializes a ModelMBean object using ModelMBeanInfo passed in. This method makes it possible to set a customized ModelMBeanInfo on the ModelMBean as long as it is not registered with the MBeanServer.
Once the ModelMBean's ModelMBeanInfo (with Descriptors) are customized and set on the ModelMBean, the ModelMBean be registered with the MBeanServer.If the ModelMBean is currently registered, this method throws a
RuntimeOperationsException
wrapping anIllegalStateException
If the given inModelMBeanInfo does not contain any
ModelMBeanNotificationInfo
for theGENERIC
orATTRIBUTE_CHANGE
notifications, then the RequiredModelMBean will supply its own defaultModelMBeanNotificationInfo
s for those missing notifications.- Specified by:
setModelMBeanInfo
in interfaceModelMBean
- Parameters:
mbi
- The ModelMBeanInfo object to be used by the ModelMBean.- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
-- Wraps an
IllegalArgumentException
if the MBeanInfo passed in parameter is null. - Wraps an
IllegalStateException
if the ModelMBean is currently registered in the MBeanServer.
- Wraps an
-
setManagedResource
public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
Sets the instance handle of the object against which to execute all methods in this ModelMBean management interface (MBeanInfo and Descriptors).- Specified by:
setManagedResource
in interfaceModelMBean
- Parameters:
mr
- Object that is the managed resourcemr_type
- The type of reference for the managed resource.
Can be: "ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference".
In this implementation only "ObjectReference" is supported.- Throws:
MBeanException
- The initializer of the object has thrown an exception.InstanceNotFoundException
- The managed resource object could not be foundInvalidTargetObjectTypeException
- The managed resource type should be "ObjectReference".RuntimeOperationsException
- Wraps aRuntimeException
when setting the resource.
-
load
public void load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
Instantiates this MBean instance with the data found for the MBean in the persistent store. The data loaded could include attribute and operation values.
This method should be called during construction or initialization of this instance, and before the MBean is registered with the MBeanServer.
If the implementation of this class does not support persistence, an
MBeanException
wrapping aServiceNotFoundException
is thrown.- Specified by:
load
in interfacePersistentMBean
- Throws:
MBeanException
- Wraps another exception, or persistence is not supportedRuntimeOperationsException
- Wraps exceptions from the persistence mechanismInstanceNotFoundException
- Could not find or load this MBean from persistent storage
-
store
public void store() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
Captures the current state of this MBean instance and writes it out to the persistent store. The state stored could include attribute and operation values.
If the implementation of this class does not support persistence, an
MBeanException
wrapping aServiceNotFoundException
is thrown.Persistence policy from the MBean and attribute descriptor is used to guide execution of this method. The MBean should be stored if 'persistPolicy' field is:
!= "never" = "always" = "onTimer" and now > 'lastPersistTime' + 'persistPeriod' = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod' = "onUnregister"
Do not store the MBean if 'persistPolicy' field is:
= "never" = "onUpdate" = "onTimer" && now < 'lastPersistTime' + 'persistPeriod'
- Specified by:
store
in interfacePersistentMBean
- Throws:
MBeanException
- Wraps another exception, or persistence is not supportedRuntimeOperationsException
- Wraps exceptions from the persistence mechanismInstanceNotFoundException
- Could not find/access the persistent store
-
getMBeanInfo
public MBeanInfo getMBeanInfo()
Returns the attributes, operations, constructors and notifications that this RequiredModelMBean exposes for management.- Specified by:
getMBeanInfo
in interfaceDynamicMBean
- Returns:
- An instance of ModelMBeanInfo allowing retrieval all attributes, operations, and Notifications of this MBean.
-
invoke
public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException
Invokes a method on or through a RequiredModelMBean and returns the result of the method execution.If the given method to be invoked, together with the provided signature, matches one of RequiredModelMbean accessible methods, this one will be call. Otherwise the call to the given method will be tried on the managed resource.
The last value returned by an operation may be cached in the operation's descriptor which is in the ModelMBeanOperationInfo's descriptor. The valid value will be in the 'value' field if there is one. If the 'currencyTimeLimit' field in the descriptor is:
- <0 Then the value is not cached and is never valid. The operation method is invoked. The 'value' and 'lastUpdatedTimeStamp' fields are cleared.
- =0 Then the value is always cached and always valid. The 'value' field is returned. If there is no 'value' field then the operation method is invoked for the attribute. The 'lastUpdatedTimeStamp' field and `value' fields are set to the operation's return value and the current time stamp.
- >0 Represents the number of seconds that the 'value'
field is valid.
The 'value' field is no longer valid when
'lastUpdatedTimeStamp' + 'currencyTimeLimit' > Now.
- When 'value' is valid, 'value' is returned.
- When 'value' is no longer valid then the operation method is invoked. The 'lastUpdatedTimeStamp' field and `value' fields are updated.
Note: because of inconsistencies in previous versions of this specification, it is recommended not to use negative or zero values for
currencyTimeLimit
. To indicate that a cached value is never valid, omit thecurrencyTimeLimit
field. To indicate that it is always valid, use a very large number for this field.- Specified by:
invoke
in interfaceDynamicMBean
- Parameters:
opName
- The name of the method to be invoked. The name can be the fully qualified method name including the classname, or just the method name if the classname is defined in the 'class' field of the operation descriptor.opArgs
- An array containing the parameters to be set when the operation is invokedsig
- An array containing the signature of the operation. The class objects will be loaded using the same class loader as the one used for loading the MBean on which the operation was invoked.- Returns:
- The object returned by the method, which represents the result of invoking the method on the specified managed resource.
- Throws:
MBeanException
- Wraps one of the following Exceptions:- An Exception thrown by the managed object's invoked method.
-
ServiceNotFoundException
: No ModelMBeanOperationInfo or no descriptor defined for the specified operation or the managed resource is null. -
InvalidTargetObjectTypeException
: The 'targetType' field value is not 'objectReference'.
ReflectionException
- Wraps anException
thrown while trying to invoke the method.RuntimeOperationsException
- Wraps anIllegalArgumentException
Method name is null.
-
getAttribute
public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException
Returns the value of a specific attribute defined for this ModelMBean. The last value returned by an attribute may be cached in the attribute's descriptor. The valid value will be in the 'value' field if there is one. If the 'currencyTimeLimit' field in the descriptor is:- <0 Then the value is not cached and is never valid. The getter method is invoked for the attribute. The 'value' and 'lastUpdatedTimeStamp' fields are cleared.
- =0 Then the value is always cached and always valid. The 'value' field is returned. If there is no'value' field then the getter method is invoked for the attribute. The 'lastUpdatedTimeStamp' field and `value' fields are set to the attribute's value and the current time stamp.
- >0 Represents the number of seconds that the 'value'
field is valid.
The 'value' field is no longer valid when
'lastUpdatedTimeStamp' + 'currencyTimeLimit' > Now.
- When 'value' is valid, 'value' is returned.
- When 'value' is no longer valid then the getter method is invoked for the attribute. The 'lastUpdatedTimeStamp' field and `value' fields are updated.
Note: because of inconsistencies in previous versions of this specification, it is recommended not to use negative or zero values for
currencyTimeLimit
. To indicate that a cached value is never valid, omit thecurrencyTimeLimit
field. To indicate that it is always valid, use a very large number for this field.If the 'getMethod' field contains the name of a valid operation descriptor, then the method described by the operation descriptor is executed. The response from the method is returned as the value of the attribute. If the operation fails or the returned value is not compatible with the declared type of the attribute, an exception will be thrown.
If no 'getMethod' field is defined then the default value of the attribute is returned. If the returned value is not compatible with the declared type of the attribute, an exception will be thrown.
The declared type of the attribute is the String returned by
MBeanAttributeInfo.getType()
. A value is compatible with this type if one of the following is true:- the value is null;
- the declared name is a primitive type name (such as "int") and the value is an instance of the corresponding wrapper type (such as java.lang.Integer);
- the name of the value's class is identical to the declared name;
- the declared name can be loaded by the value's class loader and produces a class to which the value can be assigned.
In this implementation, in every case where the getMethod needs to be called, because the method is invoked through the standard "invoke" method and thus needs operationInfo, an operation must be specified for that getMethod so that the invocation works correctly.
- Specified by:
getAttribute
in interfaceDynamicMBean
- Parameters:
attrName
- A String specifying the name of the attribute to be retrieved. It must match the name of a ModelMBeanAttributeInfo.- Returns:
- The value of the retrieved attribute from the descriptor 'value' field or from the invocation of the operation in the 'getMethod' field of the descriptor.
- Throws:
AttributeNotFoundException
- The specified attribute is not accessible in the MBean. The following cases may result in an AttributeNotFoundException:- No ModelMBeanInfo was found for the Model MBean.
- No ModelMBeanAttributeInfo was found for the specified attribute name.
- The ModelMBeanAttributeInfo isReadable method returns 'false'.
MBeanException
- Wraps one of the following Exceptions:-
InvalidAttributeValueException
: A wrong value type was received from the attribute's getter method or no 'getMethod' field defined in the descriptor for the attribute and no default value exists. -
ServiceNotFoundException
: No ModelMBeanOperationInfo defined for the attribute's getter method or no descriptor associated with the ModelMBeanOperationInfo or the managed resource is null. -
InvalidTargetObjectTypeException
The 'targetType' field value is not 'objectReference'. - An Exception thrown by the managed object's getter.
-
ReflectionException
- Wraps anException
thrown while trying to invoke the getter.RuntimeOperationsException
- Wraps anIllegalArgumentException
: The attribute name in parameter is null.- See Also:
setAttribute(javax.management.Attribute)
-
getAttributes
public AttributeList getAttributes(String[] attrNames)
Returns the values of several attributes in the ModelMBean. Executes a getAttribute for each attribute name in the attrNames array passed in.- Specified by:
getAttributes
in interfaceDynamicMBean
- Parameters:
attrNames
- A String array of names of the attributes to be retrieved.- Returns:
- The array of the retrieved attributes.
- Throws:
RuntimeOperationsException
- Wraps anIllegalArgumentException
: The object name in parameter is null or attributes in parameter is null.- See Also:
setAttributes(javax.management.AttributeList)
-
setAttribute
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
Sets the value of a specific attribute of a named ModelMBean. If the 'setMethod' field of the attribute's descriptor contains the name of a valid operation descriptor, then the method described by the operation descriptor is executed. In this implementation, the operation descriptor must be specified correctly and assigned to the modelMBeanInfo so that the 'setMethod' works correctly. The response from the method is set as the value of the attribute in the descriptor.If currencyTimeLimit is > 0, then the new value for the attribute is cached in the attribute descriptor's 'value' field and the 'lastUpdatedTimeStamp' field is set to the current time stamp.
If the persist field of the attribute's descriptor is not null then Persistence policy from the attribute descriptor is used to guide storing the attribute in a persistent store.
Store the MBean if 'persistPolicy' field is:- != "never"
- = "always"
- = "onUpdate"
- = "onTimer" and now > 'lastPersistTime' + 'persistPeriod'
- = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod'
- = "never"
- = "onTimer" && now < 'lastPersistTime' + 'persistPeriod'
- = "onUnregister"
- = "NoMoreOftenThan" and now < 'lastPersistTime' + 'persistPeriod'
The ModelMBeanInfo of the Model MBean is stored in a file.
- Specified by:
setAttribute
in interfaceDynamicMBean
- Parameters:
attribute
- The Attribute instance containing the name of the attribute to be set and the value it is to be set to.- Throws:
AttributeNotFoundException
- The specified attribute is not accessible in the MBean.
The following cases may result in an AttributeNotFoundException:- No ModelMBeanAttributeInfo is found for the specified attribute.
- The ModelMBeanAttributeInfo's isWritable method returns 'false'.
InvalidAttributeValueException
- No descriptor is defined for the specified attribute.MBeanException
- Wraps one of the following Exceptions:- An Exception thrown by the managed object's setter.
- A
ServiceNotFoundException
if a setMethod field is defined in the descriptor for the attribute and the managed resource is null; or if no setMethod field is defined and caching is not enabled for the attribute. Note that if there is no getMethod field either, then caching is automatically enabled. -
InvalidTargetObjectTypeException
The 'targetType' field value is not 'objectReference'. - An Exception thrown by the managed object's getter.
ReflectionException
- Wraps anException
thrown while trying to invoke the setter.RuntimeOperationsException
- Wraps anIllegalArgumentException
: The attribute in parameter is null.- See Also:
getAttribute(java.lang.String)
-
setAttributes
public AttributeList setAttributes(AttributeList attributes)
Sets the values of an array of attributes of this ModelMBean. Executes the setAttribute() method for each attribute in the list.- Specified by:
setAttributes
in interfaceDynamicMBean
- Parameters:
attributes
- A list of attributes: The identification of the attributes to be set and the values they are to be set to.- Returns:
- The array of attributes that were set, with their new values in Attribute instances.
- Throws:
RuntimeOperationsException
- Wraps anIllegalArgumentException
: The object name in parameter is null or attributes in parameter is null.- See Also:
getAttributes(java.lang.String[])
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException
Registers an object which implements the NotificationListener interface as a listener. This object's 'handleNotification()' method will be invoked when any notification is issued through or by the ModelMBean. This does not include attributeChangeNotifications. They must be registered for independently.- Specified by:
addNotificationListener
in interfaceNotificationBroadcaster
- Parameters:
listener
- The listener object which will handles notifications emitted by the registered MBean.filter
- The filter object. If null, no filtering will be performed before handling notifications.handback
- The context to be sent to the listener with the notification when a notification is emitted.- Throws:
IllegalArgumentException
- The listener cannot be null.- See Also:
removeNotificationListener(javax.management.NotificationListener)
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
Removes a listener for Notifications from the RequiredModelMBean.- Specified by:
removeNotificationListener
in interfaceNotificationBroadcaster
- Parameters:
listener
- The listener name which was handling notifications emitted by the registered MBean. This method will remove all information related to this listener.- Throws:
ListenerNotFoundException
- The listener is not registered in the MBean or is null.- See Also:
addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException
Description copied from interface:NotificationEmitter
Removes a listener from this MBean. The MBean must have a listener that exactly matches the given
listener
,filter
, andhandback
parameters. If there is more than one such listener, only one is removed.The
filter
andhandback
parameters may be null if and only if they are null in a listener to be removed.- Specified by:
removeNotificationListener
in interfaceNotificationEmitter
- Parameters:
listener
- A listener that was previously added to this MBean.filter
- The filter that was specified when the listener was added.handback
- The handback that was specified when the listener was added.- Throws:
ListenerNotFoundException
- The listener is not registered with the MBean, or it is not registered with the given filter and handback.
-
sendNotification
public void sendNotification(Notification ntfyObj) throws MBeanException, RuntimeOperationsException
Description copied from interface:ModelMBeanNotificationBroadcaster
Sends a Notification which is passed in to the registered Notification listeners on the ModelMBean as a jmx.modelmbean.generic notification.- Specified by:
sendNotification
in interfaceModelMBeanNotificationBroadcaster
- Parameters:
ntfyObj
- The notification which is to be passed to the 'handleNotification' method of the listener object.- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps an IllegalArgumentException: The Notification object passed in parameter is null.
-
sendNotification
public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException
Description copied from interface:ModelMBeanNotificationBroadcaster
Sends a Notification which contains the text string that is passed in to the registered Notification listeners on the ModelMBean.- Specified by:
sendNotification
in interfaceModelMBeanNotificationBroadcaster
- Parameters:
ntfyText
- The text which is to be passed in the Notification to the 'handleNotification' method of the listener object. the constructed Notification will be: type "jmx.modelmbean.generic" source this ModelMBean instance sequence 1- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps an IllegalArgumentException: The Notification text string passed in parameter is null.
-
getNotificationInfo
public MBeanNotificationInfo[] getNotificationInfo()
Returns the array of Notifications always generated by the RequiredModelMBean.RequiredModelMBean may always send also two additional notifications:
- One with descriptor
"name=GENERIC,descriptorType=notification,log=T,severity=6,displayName=jmx.modelmbean.generic"
- Second is a standard attribute change notification
with descriptor
"name=ATTRIBUTE_CHANGE,descriptorType=notification,log=T,severity=6,displayName=jmx.attribute.change"
- Specified by:
getNotificationInfo
in interfaceNotificationBroadcaster
- Returns:
- MBeanNotificationInfo[]
- One with descriptor
-
addAttributeChangeNotificationListener
public void addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException
Description copied from interface:ModelMBeanNotificationBroadcaster
Registers an object which implements the NotificationListener interface as a listener. This object's 'handleNotification()' method will be invoked when any attributeChangeNotification is issued through or by the ModelMBean. This does not include other Notifications. They must be registered for independently. An AttributeChangeNotification will be generated for this attributeName.- Specified by:
addAttributeChangeNotificationListener
in interfaceModelMBeanNotificationBroadcaster
- Parameters:
inlistener
- The listener object which will handles notifications emitted by the registered MBean.inAttributeName
- The name of the ModelMBean attribute for which to receive change notifications. If null, then all attribute changes will cause an attributeChangeNotification to be issued.inhandback
- The context to be sent to the listener with the notification when a notification is emitted.- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps an IllegalArgumentException The attribute name passed in parameter does not exist.IllegalArgumentException
- The listener cannot be null.- See Also:
ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String)
-
removeAttributeChangeNotificationListener
public void removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
Description copied from interface:ModelMBeanNotificationBroadcaster
Removes a listener for attributeChangeNotifications from the RequiredModelMBean.- Specified by:
removeAttributeChangeNotificationListener
in interfaceModelMBeanNotificationBroadcaster
- Parameters:
inlistener
- The listener name which was handling notifications emitted by the registered MBean. This method will remove all information related to this listener.inAttributeName
- The attribute for which the listener no longer wants to receive attributeChangeNotifications. If null the listener will be removed for all attributeChangeNotifications.- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps an IllegalArgumentException If the inAttributeName parameter does not correspond to an attribute name.ListenerNotFoundException
- The listener is not registered in the MBean or is null.- See Also:
ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String, java.lang.Object)
-
sendAttributeChangeNotification
public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException
Description copied from interface:ModelMBeanNotificationBroadcaster
Sends an attributeChangeNotification which is passed in to the registered attributeChangeNotification listeners on the ModelMBean.- Specified by:
sendAttributeChangeNotification
in interfaceModelMBeanNotificationBroadcaster
- Parameters:
ntfyObj
- The notification which is to be passed to the 'handleNotification' method of the listener object.- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps an IllegalArgumentException: The AttributeChangeNotification object passed in parameter is null.
-
sendAttributeChangeNotification
public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException
Description copied from interface:ModelMBeanNotificationBroadcaster
Sends an attributeChangeNotification which contains the old value and new value for the attribute to the registered AttributeChangeNotification listeners on the ModelMBean.- Specified by:
sendAttributeChangeNotification
in interfaceModelMBeanNotificationBroadcaster
- Parameters:
inOldVal
- The original value for the AttributeinNewVal
- The current value for the AttributeThe constructed attributeChangeNotification will be: type "jmx.attribute.change" source this ModelMBean instance sequence 1 attributeName oldValue.getName() attributeType oldValue's class attributeOldValue oldValue.getValue() attributeNewValue newValue.getValue()
- Throws:
MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- Wraps an IllegalArgumentException: An Attribute object passed in parameter is null or the names of the two Attribute objects in parameter are not the same.
-
getClassLoaderRepository
protected ClassLoaderRepository getClassLoaderRepository()
Return the Class Loader Repository used to perform class loading. Subclasses may wish to redefine this method in order to return the appropriateClassLoaderRepository
that should be used in this object.- Returns:
- the Class Loader Repository.
-
preRegister
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
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.In order to ensure proper run-time semantics of RequireModelMBean, Any subclass of RequiredModelMBean overloading or overriding this method should call
super.preRegister(server, name)
in its ownpreRegister
implementation.- Specified by:
preRegister
in interfaceMBeanRegistration
- Parameters:
server
- The MBean server in which the MBean will be registered.name
- The object name of the MBean. This name is null if the name parameter to one of thecreateMBean
orregisterMBean
methods in theMBeanServer
interface is null. In that case, this method must return a non-null ObjectName for the new MBean.- Returns:
- The name under which the MBean is to be registered.
This value must not be null. If the
name
parameter is not null, it will usually but not necessarily be the returned value. - Throws:
Exception
- This exception will be caught by the MBean server and re-thrown as anMBeanRegistrationException
.
-
postRegister
public void postRegister(Boolean registrationDone)
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.In order to ensure proper run-time semantics of RequireModelMBean, Any subclass of RequiredModelMBean overloading or overriding this method should call
super.postRegister(registrationDone)
in its ownpostRegister
implementation.- 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
Allows the MBean to perform any operations it needs before being unregistered by the MBean server.In order to ensure proper run-time semantics of RequireModelMBean, Any subclass of RequiredModelMBean overloading or overriding this method should call
super.preDeregister()
in its ownpreDeregister
implementation.- Specified by:
preDeregister
in interfaceMBeanRegistration
- Throws:
Exception
- This exception will be caught by the MBean server and re-thrown as anMBeanRegistrationException
.
-
postDeregister
public void postDeregister()
Allows the MBean to perform any operations needed after having been unregistered in the MBean server.In order to ensure proper run-time semantics of RequireModelMBean, Any subclass of RequiredModelMBean overloading or overriding this method should call
super.postDeregister()
in its ownpostDeregister
implementation.- Specified by:
postDeregister
in interfaceMBeanRegistration
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
17/11/2024 17:31:56 Cette version de la page est en cache (à la date du 17/11/2024 17:31:56) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 16/09/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/management/modelmbean/requiredmodelmbean.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.