Top Description Fields Constructors Methods
javax.management.modelmbean

public Class RequiredModelMBean

extends Object
implements ModelMBean, MBeanRegistration, NotificationEmitter
Class Inheritance
All Implemented Interfaces
javax.management.NotificationEmitter, javax.management.NotificationBroadcaster, javax.management.MBeanRegistration, javax.management.modelmbean.ModelMBean, javax.management.modelmbean.ModelMBeanNotificationBroadcaster, javax.management.PersistentMBean, javax.management.DynamicMBean
Static Imports
com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER

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

Field Summary

Modifier and TypeField and Description
private final AccessControlContext
acc

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
private NotificationBroadcasterSupport
private NotificationBroadcasterSupport
private static final JavaSecurityAccess
private Object
pack-priv ModelMBeanInfo
private static final Class<?>[]
private static final Map<String, Class<?>>
private static final String[]
private static final String[]
private boolean
private static Set<String>
private transient MBeanServer

Constructor Summary

AccessConstructor and Description
public
RequiredModelMBean()

Constructs an RequiredModelMBean with an empty ModelMBeanInfo.

public
RequiredModelMBean(ModelMBeanInfo
The ModelMBeanInfo object to be used by the RequiredModelMBean. The given ModelMBeanInfo is cloned and modified as specified by setModelMBeanInfo
mbi
)

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 the setModelMBeanInfo method.

Method Summary

Modifier and TypeMethod and Description
public void
addAttributeChangeNotificationListener(NotificationListener
The listener object which will handles notifications emitted by the registered MBean.
inlistener
,
String
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.
inAttributeName
,
Object
The context to be sent to the listener with the notification when a notification is emitted.
inhandback
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener.

Registers an object which implements the NotificationListener interface as a listener.

public void
addNotificationListener(NotificationListener
The listener object which will handles notifications emitted by the registered MBean.
listener
,
NotificationFilter
The filter object. If null, no filtering will be performed before handling notifications.
filter
,
Object
The context to be sent to the listener with the notification when a notification is emitted.
handback
)

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Registers an object which implements the NotificationListener interface as a listener.

private void
private ModelMBeanInfo
private Method
findRMMBMethod(String opMethodName, Object targetObjectField, String opClassName, String[] sig)

public Object

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.
getAttribute
(String
A String specifying the name of the attribute to be retrieved. It must match the name of a ModelMBeanAttributeInfo.
attrName
)

Implements javax.management.DynamicMBean.getAttribute.

Returns the value of a specific attribute defined for this ModelMBean.

public AttributeList

Returns:

The array of the retrieved attributes.
getAttributes
(String[]
A String array of names of the attributes to be retrieved.
attrNames
)

Implements javax.management.DynamicMBean.getAttributes.

Returns the values of several attributes in the ModelMBean.

protected ClassLoaderRepository

Returns:

the Class Loader Repository.
getClassLoaderRepository
()

Return the Class Loader Repository used to perform class loading.

public MBeanInfo

Returns:

An instance of ModelMBeanInfo allowing retrieval all attributes, operations, and Notifications of this MBean.
getMBeanInfo
()

Implements javax.management.DynamicMBean.getMBeanInfo.

Returns the attributes, operations, constructors and notifications that this RequiredModelMBean exposes for management.

public MBeanNotificationInfo[]

Returns:

MBeanNotificationInfo[]
getNotificationInfo
()

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Returns the array of Notifications always generated by the RequiredModelMBean.

private static final boolean
hasNotification(final ModelMBeanInfo info, final String notifName)

Returns `true' if the notification `notifName' is found in `info'.

public Object

Returns:

The object returned by the method, which represents the result of invoking the method on the specified managed resource.
invoke
(String
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.
opName
,
Object[]
An array containing the parameters to be set when the operation is invoked
opArgs
,
String[]
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.
sig
)

Implements javax.management.DynamicMBean.invoke.

Invokes a method on or through a RequiredModelMBean and returns the result of the method execution.

private Object
invokeMethod(String opName, final Method method, final Object targetObject, final Object[] opArgs)

private static synchronized boolean
public void
load()

Implements javax.management.PersistentMBean.load.

Instantiates this MBean instance with the data found for the MBean in the persistent store.

private Class<?>
loadClass(final String className)

private static final ModelMBeanNotificationInfo
makeAttributeChangeInfo()

Creates a default ModelMBeanNotificationInfo for ATTRIBUTE_CHANGE notification.

private static final ModelMBeanNotificationInfo
makeGenericInfo()

Creates a default ModelMBeanNotificationInfo for GENERIC notification.

public void
postDeregister()

Implements javax.management.MBeanRegistration.postDeregister.

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

public void
postRegister(Boolean
Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.
registrationDone
)

Implements javax.management.MBeanRegistration.postRegister.

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

public void
preDeregister()

Implements javax.management.MBeanRegistration.preDeregister.

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

public ObjectName

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.
preRegister
(MBeanServer
The MBean server in which the MBean will be registered.
server
,
ObjectName
The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.
name
)

Implements javax.management.MBeanRegistration.preRegister.

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

private String
public void
removeAttributeChangeNotificationListener(NotificationListener
The listener name which was handling notifications emitted by the registered MBean. This method will remove all information related to this listener.
inlistener
,
String
The attribute for which the listener no longer wants to receive attributeChangeNotifications. If null the listener will be removed for all attributeChangeNotifications.
inAttributeName
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener.

Removes a listener for attributeChangeNotifications from the RequiredModelMBean.

public void
removeNotificationListener(NotificationListener
The listener name which was handling notifications emitted by the registered MBean. This method will remove all information related to this listener.
listener
)

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Removes a listener for Notifications from the RequiredModelMBean.

public void
removeNotificationListener(NotificationListener
A listener that was previously added to this MBean.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
handback
)

Implements javax.management.NotificationEmitter.removeNotificationListener.

Removes a listener from this MBean.

private Object
resolveForCacheValue(Descriptor descr)

The resolveForCacheValue method checks the descriptor passed in to see if there is a valid cached value in the descriptor.

private Method
resolveMethod(Class<?> targetClass, String opMethodName, final String[] sig)

public void
sendAttributeChangeNotification(AttributeChangeNotification
The notification which is to be passed to the 'handleNotification' method of the listener object.
ntfyObj
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Sends an attributeChangeNotification which is passed in to the registered attributeChangeNotification listeners on the ModelMBean.

public void
sendAttributeChangeNotification(Attribute
The original value for the Attribute
inOldVal
,
Attribute
The current value for the Attribute
The 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()
inNewVal
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Sends an attributeChangeNotification which contains the old value and new value for the attribute to the registered AttributeChangeNotification listeners on the ModelMBean.

public void
sendNotification(Notification
The notification which is to be passed to the 'handleNotification' method of the listener object.
ntfyObj
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Sends a Notification which is passed in to the registered Notification listeners on the ModelMBean as a jmx.modelmbean.generic notification.

public void
sendNotification(String
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
ntfyText
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Sends a Notification which contains the text string that is passed in to the registered Notification listeners on the ModelMBean.

public void
setAttribute(Attribute
The Attribute instance containing the name of the attribute to be set and the value it is to be set to.
attribute
)

Implements javax.management.DynamicMBean.setAttribute.

Sets the value of a specific attribute of a named ModelMBean.

public AttributeList

Returns:

The array of attributes that were set, with their new values in Attribute instances.
setAttributes
(AttributeList
A list of attributes: The identification of the attributes to be set and the values they are to be set to.
attributes
)

Implements javax.management.DynamicMBean.setAttributes.

Sets the values of an array of attributes of this ModelMBean.

public void
setManagedResource(Object
Object that is the managed resource
mr
,
String
The type of reference for the managed resource.
Can be: "ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference".
In this implementation only "ObjectReference" is supported.
mr_type
)

Implements javax.management.modelmbean.ModelMBean.setManagedResource.

Sets the instance handle of the object against which to execute all methods in this ModelMBean management interface (MBeanInfo and Descriptors).

public void
setModelMBeanInfo(ModelMBeanInfo
The ModelMBeanInfo object to be used by the ModelMBean.
mbi
)

Implements javax.management.modelmbean.ModelMBean.setModelMBeanInfo.

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.

public void
store()

Implements javax.management.PersistentMBean.store.

Captures the current state of this MBean instance and writes it out to the persistent store.

private synchronized void
writeToLog(String logFileName, String logEntry)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accback to summary
private final AccessControlContext acc

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@SuppressWarnings:removal
attributeBroadcasterback to summary
private NotificationBroadcasterSupport attributeBroadcaster
generalBroadcasterback to summary
private NotificationBroadcasterSupport generalBroadcaster
javaSecurityAccessback to summary
private static final JavaSecurityAccess javaSecurityAccess
managedResourceback to summary
private Object managedResource
modelMBeanInfoback to summary
pack-priv ModelMBeanInfo modelMBeanInfo
primitiveClassesback to summary
private static final Class<?>[] primitiveClasses
primitiveClassMapback to summary
private static final Map<String, Class<?>> primitiveClassMap
primitiveTypesback to summary
private static final String[] primitiveTypes
primitiveWrappersback to summary
private static final String[] primitiveWrappers
registeredback to summary
private boolean registered
rmmbMethodNamesback to summary
private static Set<String> rmmbMethodNames
serverback to summary
private transient MBeanServer server

Constructor Detail

RequiredModelMBeanback to summary
public RequiredModelMBean() throws MBeanException, RuntimeOperationsException

Constructs an RequiredModelMBean with an empty ModelMBeanInfo.

The RequiredModelMBean's MBeanInfo and Descriptors can be customized using the setModelMBeanInfo method. After the RequiredModelMBean's MBeanInfo and Descriptors are customized, the RequiredModelMBean can be registered with the MBeanServer.

Exceptions
MBeanException:
Wraps a distributed communication Exception.
RuntimeOperationsException:
Wraps a RuntimeException during the construction of the object.
RequiredModelMBeanback to summary
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 the setModelMBeanInfo method. After the RequiredModelMBean's MBeanInfo and Descriptors are customized, the RequiredModelMBean can be registered with the MBeanServer.

Parameters
mbi:ModelMBeanInfo

The ModelMBeanInfo object to be used by the RequiredModelMBean. The given ModelMBeanInfo is cloned and modified as specified by setModelMBeanInfo

Exceptions
MBeanException:
Wraps a distributed communication Exception.
RuntimeOperationsException:
Wraps an java.lang.IllegalArgumentException: The MBeanInfo passed in parameter is null.

Method Detail

addAttributeChangeNotificationListenerback to summary
public void addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener.

Doc from javax.management.modelmbean.ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener.

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.

Parameters
inlistener:NotificationListener

The listener object which will handles notifications emitted by the registered MBean.

inAttributeName:String

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:Object

The context to be sent to the listener with the notification when a notification is emitted.

Exceptions
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.
addNotificationListenerback to summary
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException

Implements javax.management.NotificationBroadcaster.addNotificationListener.

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.

Parameters
listener:NotificationListener

The listener object which will handles notifications emitted by the registered MBean.

filter:NotificationFilter

The filter object. If null, no filtering will be performed before handling notifications.

handback:Object

The context to be sent to the listener with the notification when a notification is emitted.

Exceptions
IllegalArgumentException:
The listener cannot be null.
See Also
removeNotificationListener
cacheResultback to summary
private void cacheResult(ModelMBeanOperationInfo opInfo, Descriptor opDescr, Object result) throws MBeanException
createDefaultModelMBeanInfoback to summary
private ModelMBeanInfo createDefaultModelMBeanInfo()
findRMMBMethodback to summary
private Method findRMMBMethod(String opMethodName, Object targetObjectField, String opClassName, String[] sig)
getAttributeback to summary
public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException

Implements javax.management.DynamicMBean.getAttribute.

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 the currencyTimeLimit 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 ModelMBeanAttributeInfo#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.

Parameters
attrName:String

A String specifying the name of the attribute to be retrieved. It must match the name of a ModelMBeanAttributeInfo.

Returns:Object

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.

Exceptions
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 an java.lang.Exception thrown while trying to invoke the getter.
RuntimeOperationsException:
Wraps an IllegalArgumentException: The attribute name in parameter is null.
See Also
setAttribute(javax.management.Attribute)
getAttributesback to summary
public AttributeList getAttributes(String[] attrNames)

Implements javax.management.DynamicMBean.getAttributes.

Returns the values of several attributes in the ModelMBean. Executes a getAttribute for each attribute name in the attrNames array passed in.

Parameters
attrNames:String[]

A String array of names of the attributes to be retrieved.

Returns:AttributeList

The array of the retrieved attributes.

Exceptions
RuntimeOperationsException:
Wraps an IllegalArgumentException: The object name in parameter is null or attributes in parameter is null.
See Also
setAttributes(javax.management.AttributeList)
getClassLoaderRepositoryback to summary
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 appropriate javax.management.loading.ClassLoaderRepository that should be used in this object.

Returns:ClassLoaderRepository

the Class Loader Repository.

getMBeanInfoback to summary
public MBeanInfo getMBeanInfo()

Implements javax.management.DynamicMBean.getMBeanInfo.

Returns the attributes, operations, constructors and notifications that this RequiredModelMBean exposes for management.

Returns:MBeanInfo

An instance of ModelMBeanInfo allowing retrieval all attributes, operations, and Notifications of this MBean.

getNotificationInfoback to summary
public MBeanNotificationInfo[] getNotificationInfo()

Implements javax.management.NotificationBroadcaster.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"
Thus these two notifications are always added to those specified by the application.
Returns:MBeanNotificationInfo[]

MBeanNotificationInfo[]

hasNotificationback to summary
private static final boolean hasNotification(final ModelMBeanInfo info, final String notifName)

Returns `true' if the notification `notifName' is found in `info'. (bug 4744667)

invokeback to summary
public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException

Implements javax.management.DynamicMBean.invoke.

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 the currencyTimeLimit field. To indicate that it is always valid, use a very large number for this field.

Parameters
opName:String

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:Object[]

An array containing the parameters to be set when the operation is invoked

sig:String[]

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:Object

The object returned by the method, which represents the result of invoking the method on the specified managed resource.

Exceptions
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 an java.lang.Exception thrown while trying to invoke the method.
RuntimeOperationsException:
Wraps an IllegalArgumentException Method name is null.
invokeMethodback to summary
private Object invokeMethod(String opName, final Method method, final Object targetObject, final Object[] opArgs) throws MBeanException, ReflectionException
isRMMBMethodNameback to summary
private static synchronized boolean isRMMBMethodName(String name)
loadback to summary
public void load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException

Implements javax.management.PersistentMBean.load.

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 a ServiceNotFoundException is thrown.

Exceptions
MBeanException:
Wraps another exception, or persistence is not supported
RuntimeOperationsException:
Wraps exceptions from the persistence mechanism
InstanceNotFoundException:
Could not find or load this MBean from persistent storage
loadClassback to summary
private Class<?> loadClass(final String className) throws ClassNotFoundException
makeAttributeChangeInfoback to summary
private static final ModelMBeanNotificationInfo makeAttributeChangeInfo()

Creates a default ModelMBeanNotificationInfo for ATTRIBUTE_CHANGE notification. (bug 4744667)

makeGenericInfoback to summary
private static final ModelMBeanNotificationInfo makeGenericInfo()

Creates a default ModelMBeanNotificationInfo for GENERIC notification. (bug 4744667)

postDeregisterback to summary
public void postDeregister()

Implements javax.management.MBeanRegistration.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 own postDeregister implementation.

postRegisterback to summary
public void postRegister(Boolean registrationDone)

Implements javax.management.MBeanRegistration.postRegister.

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 own postRegister implementation.

Parameters
registrationDone:Boolean

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

preDeregisterback to summary
public void preDeregister() throws Exception

Implements javax.management.MBeanRegistration.preDeregister.

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 own preDeregister implementation.

Exceptions
Exception:
This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
preRegisterback to summary
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception

Implements javax.management.MBeanRegistration.preRegister.

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 own preRegister implementation.

Parameters
server:MBeanServer

The MBean server in which the MBean will be registered.

name:ObjectName

The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.

Returns:ObjectName

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.

Exceptions
Exception:
This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
printModelMBeanInfoback to summary
private String printModelMBeanInfo(ModelMBeanInfo info)
removeAttributeChangeNotificationListenerback to summary
public void removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener.

Doc from javax.management.modelmbean.ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener.

Removes a listener for attributeChangeNotifications from the RequiredModelMBean.

Parameters
inlistener:NotificationListener

The listener name which was handling notifications emitted by the registered MBean. This method will remove all information related to this listener.

inAttributeName:String

The attribute for which the listener no longer wants to receive attributeChangeNotifications. If null the listener will be removed for all attributeChangeNotifications.

Exceptions
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.
removeNotificationListenerback to summary
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Removes a listener for Notifications from the RequiredModelMBean.

Parameters
listener:NotificationListener

The listener name which was handling notifications emitted by the registered MBean. This method will remove all information related to this listener.

Exceptions
ListenerNotFoundException:
The listener is not registered in the MBean or is null.
See Also
addNotificationListener
removeNotificationListenerback to summary
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException

Implements javax.management.NotificationEmitter.removeNotificationListener.

Doc from javax.management.NotificationEmitter.removeNotificationListener.

Removes a listener from this MBean. The MBean must have a listener that exactly matches the given listener, filter, and handback parameters. If there is more than one such listener, only one is removed.

The filter and handback parameters may be null if and only if they are null in a listener to be removed.

Parameters
listener:NotificationListener

A listener that was previously added to this MBean.

filter:NotificationFilter

The filter that was specified when the listener was added.

handback:Object

The handback that was specified when the listener was added.

Exceptions
ListenerNotFoundException:
The listener is not registered with the MBean, or it is not registered with the given filter and handback.
resolveForCacheValueback to summary
private Object resolveForCacheValue(Descriptor descr) throws MBeanException, RuntimeOperationsException

The resolveForCacheValue method checks the descriptor passed in to see if there is a valid cached value in the 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. Null is returned. The 'value' and 'lastUpdatedTimeStamp' fields are cleared.
  • =0 Then the value is always cached and always valid. 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 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.
resolveMethodback to summary
private Method resolveMethod(Class<?> targetClass, String opMethodName, final String[] sig) throws ReflectionException
sendAttributeChangeNotificationback to summary
public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Doc from javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Sends an attributeChangeNotification which is passed in to the registered attributeChangeNotification listeners on the ModelMBean.

Parameters
ntfyObj:AttributeChangeNotification

The notification which is to be passed to the 'handleNotification' method of the listener object.

Exceptions
MBeanException:
Wraps a distributed communication Exception.
RuntimeOperationsException:
Wraps an IllegalArgumentException: The AttributeChangeNotification object passed in parameter is null.
sendAttributeChangeNotificationback to summary
public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Doc from javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Sends an attributeChangeNotification which contains the old value and new value for the attribute to the registered AttributeChangeNotification listeners on the ModelMBean.

Parameters
inOldVal:Attribute

The original value for the Attribute

inNewVal:Attribute

The current value for the Attribute

The 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()
Exceptions
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.
sendNotificationback to summary
public void sendNotification(Notification ntfyObj) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Doc from javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Sends a Notification which is passed in to the registered Notification listeners on the ModelMBean as a jmx.modelmbean.generic notification.

Parameters
ntfyObj:Notification

The notification which is to be passed to the 'handleNotification' method of the listener object.

Exceptions
MBeanException:
Wraps a distributed communication Exception.
RuntimeOperationsException:
Wraps an IllegalArgumentException: The Notification object passed in parameter is null.
sendNotificationback to summary
public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Doc from javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Sends a Notification which contains the text string that is passed in to the registered Notification listeners on the ModelMBean.

Parameters
ntfyText:String

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

Exceptions
MBeanException:
Wraps a distributed communication Exception.
RuntimeOperationsException:
Wraps an IllegalArgumentException: The Notification text string passed in parameter is null.
setAttributeback to summary
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException

Implements javax.management.DynamicMBean.setAttribute.

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'
Do not store the MBean if 'persistPolicy' field is:
  • = "never"
  • = = "onTimer" && now < 'lastPersistTime' + 'persistPeriod'
  • = "onUnregister"
  • = = "NoMoreOftenThan" and now < 'lastPersistTime' + 'persistPeriod'

The ModelMBeanInfo of the Model MBean is stored in a file.

Parameters
attribute:Attribute

The Attribute instance containing the name of the attribute to be set and the value it is to be set to.

Exceptions
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 an java.lang.Exception thrown while trying to invoke the setter.
RuntimeOperationsException:
Wraps an IllegalArgumentException: The attribute in parameter is null.
See Also
getAttribute(java.lang.String)
setAttributesback to summary
public AttributeList setAttributes(AttributeList attributes)

Implements javax.management.DynamicMBean.setAttributes.

Sets the values of an array of attributes of this ModelMBean. Executes the setAttribute() method for each attribute in the list.

Parameters
attributes:AttributeList

A list of attributes: The identification of the attributes to be set and the values they are to be set to.

Returns:AttributeList

The array of attributes that were set, with their new values in Attribute instances.

Exceptions
RuntimeOperationsException:
Wraps an IllegalArgumentException: The object name in parameter is null or attributes in parameter is null.
See Also
getAttributes
setManagedResourceback to summary
public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException

Implements javax.management.modelmbean.ModelMBean.setManagedResource.

Sets the instance handle of the object against which to execute all methods in this ModelMBean management interface (MBeanInfo and Descriptors).

Parameters
mr:Object

Object that is the managed resource

mr_type:String

The type of reference for the managed resource.
Can be: "ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference".
In this implementation only "ObjectReference" is supported.

Exceptions
MBeanException:
The initializer of the object has thrown an exception.
RuntimeOperationsException:
Wraps a RuntimeException when setting the resource.
InstanceNotFoundException:
The managed resource object could not be found
InvalidTargetObjectTypeException:
The managed resource type should be "ObjectReference".
setModelMBeanInfoback to summary
public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBean.setModelMBeanInfo.

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 javax.management.RuntimeOperationsException wrapping an IllegalStateException

If the given inModelMBeanInfo does not contain any ModelMBeanNotificationInfo for the GENERIC or ATTRIBUTE_CHANGE notifications, then the RequiredModelMBean will supply its own default ModelMBeanNotificationInfos for those missing notifications.

Parameters
mbi:ModelMBeanInfo

The ModelMBeanInfo object to be used by the ModelMBean.

Exceptions
MBeanException:
Wraps a distributed communication Exception.
RuntimeOperationsException:
storeback to summary
public void store() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException

Implements javax.management.PersistentMBean.store.

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 a ServiceNotFoundException 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'
Exceptions
MBeanException:
Wraps another exception, or persistence is not supported
RuntimeOperationsException:
Wraps exceptions from the persistence mechanism
InstanceNotFoundException:
Could not find/access the persistent store
writeToLogback to summary
private synchronized void writeToLog(String logFileName, String logEntry) throws Exception