|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.management.modelmbean.RequiredModelMBean
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 instatiate 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/adapters 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 RuntimeOperatiosException must be thrown on every public method. This allows for wrappering exceptions from distributed communications (RMI, EJB, etc.).
Constructor Summary | |
RequiredModelMBean()
Constructs an RequiredModelMBean with an empty ModelMBeanInfo. |
|
RequiredModelMBean(ModelMBeanInfo mbi)
Constructs a RequiredModelMBean object using ModelMBeanInfo passed in. |
Method Summary | |
void |
addAttributeChangeNotificationListener(NotificationListener inlistener,
java.lang.String inAttributeName,
java.lang.Object inhandback)
Registers an object which implements the NotificationListener interface as a listener. |
void |
addNotificationListener(NotificationListener inlistener,
NotificationFilter infilter,
java.lang.Object inhandback)
Registers an object which implements the NotificationListener interface as a listener. |
java.lang.Object |
getAttribute(java.lang.String attrName)
Returns the value of a specific attribute defined for this ModelMBean. |
AttributeList |
getAttributes(java.lang.String[] attrNames)
Returns the values of several attributes in the ModelMBean. |
MBeanInfo |
getMBeanInfo()
Returns the attributes, operations, and notifications that this RequiredModelMBean exposes for management. |
MBeanNotificationInfo[] |
getNotificationInfo()
Returns the array of Notifications always generated by the RequiredModelMBean. |
java.lang.Object |
invoke(java.lang.String opName,
java.lang.Object[] opArgs,
java.lang.String[] sig)
Invokes a method on or through a RequiredModelMBean and returns the result of the method execution. |
void |
load()
The load method instantiates this RequiredModelMBean instance with the data found for the RequiredModelMBean in the persistent store. |
void |
removeAttributeChangeNotificationListener(NotificationListener inlistener,
java.lang.String inAttributeName)
Removes a listener for attributeChangeNotifications from the RequiredModelMBean. |
void |
removeNotificationListener(NotificationListener inlistener)
Removes a listener for Notifications from the RequiredModelMBean. |
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 RequiredModelMBean. |
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 RequiredModelMBean. |
void |
sendNotification(java.lang.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(java.lang.Object mr,
java.lang.String mr_type)
Sets the instance handle of the object against which to execute all methods in this RequiredModelMBean management interface (ModelMBeanInfo and Descriptors). |
void |
setModelMBeanInfo(ModelMBeanInfo mbi)
Initializes a RequiredModelMBean object using ModelMBeanInfo passed in. |
void |
store()
Captures the current state of this RequiredModelMBean instance and writes it out to the persistent store. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public RequiredModelMBean() throws MBeanException, RuntimeOperationsException
public RequiredModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
mbi
- The ModelMBeanInfo object to be used by the
RequiredModelMBean.Method Detail |
public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
mbi
- The MBeanInfo object to be used by the
RequiredModelMBean.public void setManagedResource(java.lang.Object mr, java.lang.String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
mr
- Object that is the managed resourcemr_type
- The type of reference for the managed resource.
Can be: ObjectReference, Handle, IOR, EJBHandle, RMIReference.
If the MBeanServer cannot process the mr_type passed in,
an exception will be thrown.public void load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
public void store() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
Store the MBean if 'persistPolicy' field is: != "never" = "always" = "onTimer" and now < 'lastPersistTime' + 'persistPeriod' = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod' Do not store the MBean if 'persistPolicy' field is: = "never" = "onUpdate" = "onTimer" && now > 'lastPersistTime' + 'persistPeriod'The data stored will include a serialized ModelMBeanInfo. If there are object references in the descriptors which are not serializeable, then persistence will fail.
public MBeanInfo getMBeanInfo()
public java.lang.Object invoke(java.lang.String opName, java.lang.Object[] opArgs, java.lang.String[] sig) throws MBeanException, ReflectionException, RuntimeOperationsException
If the 'currencyTimeLimit' field in the descriptor is: <0 Then the value is always cached and is never stale. Hence the first time the method will be invoked, afterwhich the cache is always used. =0 Then the value is always stale. The cache is never used, so the method is invoked. The 'value' field is returned. The 'lastUpdatedTimeStamp' field is not checked. >0 Represents the number of seconds that the 'value' field is valid. The 'value' field is no longer valid (the cache is stale) when 'lastUpdatedTimeStamp' + 'currencyTimeLimit' > Now. When 'value' is valid, 'valid' is returned. When 'value' is no longer valid then null is returned and 'value' and 'lastUpdatedTimeStamp' fields are cleared. Note: For this implementation: if the cached value is not a String, then the object must have a constructor which accepts a string in the same format as the objects toString() method creates.
operationName
- 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.params
- An array containing the parameters to be set
when the operation is invokedsignature
- 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 operatoion was invoked.public java.lang.Object getAttribute(java.lang.String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException, RuntimeOperationsException
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 always cached and is never stale. Null is returned. The 'value' and 'lastUpdatedTimeStamp' fields are cleared. =0 Then the value is always stale. The cache is never used, so the 'value' field is returned. The 'lastUpdatedTimeStamp' field is not checked. >0 Represents the number of seconds that the 'value' field is valid. The 'value' field is no longer valid (the cache is stale) when 'lastUpdatedTimeStamp' + 'currencyTimeLimit' > Now. When 'value' is valid, 'valid' is returned. When 'value' is no longer valid then null is returned and 'value' and 'lastUpdatedTimeStamp' fields are cleared.If there is no valid cached value then the 'getMethod' field in the attributes descriptor is analyzed. If 'getMethod' 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 response value is not of the same type as the attribute, an exception will be thrown. If currencyTimeLimit is > 0, then the value of the attribute is cached in the attribute descriptor's 'value' field and the 'lastUpdatedTimeStamp' field is set to the current time stamp.
attributeName
- A String specifying the name of the
attribute to be retrieved. It must match the name of a
ModelMBeanAttributeInfo.public AttributeList getAttributes(java.lang.String[] attrNames) throws RuntimeOperationsException
attributes
- A String array of names of the attributes
to be retrieved.public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
Store the MBean if 'persistPolicy' field is: != "never" = "always" = "onUpdate" = "onTimer" and now > 'lastPersistTime' + 'persistPeriod' = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod' Do not store the MBean if 'persistPolicy' field is: = "never" = "onTimer" && now < 'lastPersistTime' + 'persistPeriod' = "NoMoreOftenThan" and now < 'lastPersistTime' + 'persistPeriod'
attribute
- The Attribute instance containing the name
of the attribute to be set and the value it is to be set to.public AttributeList setAttributes(AttributeList attributes) throws RuntimeOperationsException
attributes
- A list of attributes: The identification of
the attributes to be set and the values they are to be set to.public void addNotificationListener(NotificationListener inlistener, NotificationFilter infilter, java.lang.Object inhandback) throws java.lang.IllegalArgumentException
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.public void removeNotificationListener(NotificationListener inlistener) throws ListenerNotFoundException
listener
- The listener name which was handling
notifications emitted by the registered MBean. This method will
remove all information related to this listener.public void sendNotification(Notification ntfyObj) throws MBeanException, RuntimeOperationsException
notification
- The notification which is to be passed
to the 'handleNotification' method of the listener object.public void sendNotification(java.lang.String ntfyText) throws MBeanException, RuntimeOperationsException
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.general" source this ModelMBean instance
sequence 1public MBeanNotificationInfo[] getNotificationInfo()
public void addAttributeChangeNotificationListener(NotificationListener inlistener, java.lang.String inAttributeName, java.lang.Object inhandback) throws MBeanException, RuntimeOperationsException, java.lang.IllegalArgumentException
listener
- The listener object which will handles
notifications emitted by the registered MBean.attributeName
- 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.handback
- The context to be sent to the listener with
the notification when a notification is emitted.public void removeAttributeChangeNotificationListener(NotificationListener inlistener, java.lang.String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
listener
- The listener name which was handling
notifications emitted by the registered MBean. This method will
remove all information related to this listener.attributeName
- The attribute for which the listener no
longer wants to receive attributeChangeNotifications.public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException
notification
- The notification which is to be passed
to the 'handleNotification' method of the listener object.public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException
oldValue
- The origional value for the AttributenewValue
- The current value for the Attribute
The constructed attributeChangeNotification will be:
type "jmx.attribute.change"
source this RequiredModelMBean instance
sequence 1
attributeName oldValue.getName()
attributeType oldValue's class
attributeOldValue oldValue.getValue()
attributeNewValue newValue.getValue()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |