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.)
Modifier and Type | Field 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 | |
private static final String[] | |
private static final String[] | |
private boolean | |
private static Set | |
private transient MBeanServer |
Access | Constructor and Description |
---|---|
public | |
public | RequiredModelMBean(ModelMBeanInfo
The ModelMBeanInfo object to be used by the
RequiredModelMBean. The given ModelMBeanInfo is cloned
and modified as specified by mbi)setModelMBeanInfo 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 |
Modifier and Type | Method 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. 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. Registers an object which implements the NotificationListener interface as a listener. |
private void | |
private ModelMBeanInfo | |
private Method | |
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.A String specifying the name of the
attribute to be retrieved. It must match the name of a
ModelMBeanAttributeInfo. attrName)Implements javax. Returns the value of a specific attribute defined for this ModelMBean. |
public AttributeList | Returns: The array of the retrieved attributes.A String array of names of the attributes
to be retrieved. attrNames)Implements javax. Returns the values of several attributes in the ModelMBean. |
protected ClassLoaderRepository | Returns: the Class Loader Repository.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.Implements javax. Returns the attributes, operations, constructors and notifications that this RequiredModelMBean exposes for management. |
public MBeanNotificationInfo[] | Returns: MBeanNotificationInfo[]Implements javax. 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.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. Invokes a method on or through a RequiredModelMBean and returns the result of the method execution. |
private Object | |
private static synchronized boolean | |
public void | load()
Implements javax. Instantiates this MBean instance with the data found for the MBean in the persistent store. |
private Class | |
private static final ModelMBeanNotificationInfo | makeAttributeChangeInfo()
Creates a default ModelMBeanNotificationInfo for ATTRIBUTE_CHANGE notification. |
private static final ModelMBeanNotificationInfo | |
public void | postDeregister()
Implements javax. 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. 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. 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 thename
parameter is not null, it will usually but not necessarily be
the returned value.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 name)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.Implements javax. 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. 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. 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. 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 | |
public void | sendAttributeChangeNotification(AttributeChangeNotification
The notification which is to be passed
to the 'handleNotification' method of the listener object. ntfyObj)Implements javax. 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
inNewVal)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() Implements javax. 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. 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. 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. 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.A list of attributes: The identification of the
attributes to be set and the values they are to be set to. attributes)Implements javax. 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.
mr_type)Can be: "ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference". In this implementation only "ObjectReference" is supported. Implements javax. 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. 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. Captures the current state of this MBean instance and writes it out to the persistent store. |
private synchronized void |
acc | back to summary |
---|---|
private final AccessControlContext acc
References Deprecated
See corresponding docs for further information.
|
attributeBroadcaster | back to summary |
---|---|
private NotificationBroadcasterSupport attributeBroadcaster |
generalBroadcaster | back to summary |
---|---|
private NotificationBroadcasterSupport generalBroadcaster |
javaSecurityAccess | back to summary |
---|---|
private static final JavaSecurityAccess javaSecurityAccess |
managedResource | back to summary |
---|---|
private Object managedResource |
modelMBeanInfo | back to summary |
---|---|
pack-priv ModelMBeanInfo modelMBeanInfo |
primitiveClasses | back to summary |
---|---|
private static final Class<?>[] primitiveClasses |
primitiveClassMap | back to summary |
---|---|
private static final Map<String, Class<?>> primitiveClassMap |
primitiveTypes | back to summary |
---|---|
private static final String[] primitiveTypes |
primitiveWrappers | back to summary |
---|---|
private static final String[] primitiveWrappers |
registered | back to summary |
---|---|
private boolean registered |
rmmbMethodNames | back to summary |
---|---|
private static Set<String> rmmbMethodNames |
server | back to summary |
---|---|
private transient MBeanServer server |
RequiredModelMBean | back to summary |
---|---|
public RequiredModelMBean() throws MBeanException, RuntimeOperationsException Constructs an
The RequiredModelMBean's MBeanInfo and Descriptors
can be customized using the
|
RequiredModelMBean | back 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
|
addAttributeChangeNotificationListener | back to summary |
---|---|
public void addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException Implements javax. Doc from javax. 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.
|
addNotificationListener | back to summary |
---|---|
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException Implements javax. 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.
|
cacheResult | back to summary |
---|---|
private void cacheResult(ModelMBeanOperationInfo opInfo, Descriptor opDescr, Object result) throws MBeanException |
createDefaultModelMBeanInfo | back to summary |
---|---|
private ModelMBeanInfo createDefaultModelMBeanInfo() |
findRMMBMethod | back to summary |
---|---|
private Method findRMMBMethod(String opMethodName, Object targetObjectField, String opClassName, String[] sig) |
getAttribute | back to summary |
---|---|
public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException Implements javax. 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:
Note because of inconsistencies in previous versions of
this specification, it is recommended not to use negative or zero
values for 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
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.
|
getAttributes | back to summary |
---|---|
public AttributeList getAttributes(String[] attrNames) Implements javax. Returns the values of several attributes in the ModelMBean. Executes a getAttribute for each attribute name in the attrNames array passed in.
|
getClassLoaderRepository | back 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
|
getMBeanInfo | back to summary |
---|---|
public MBeanInfo getMBeanInfo() Implements javax. Returns the attributes, operations, constructors and notifications that this RequiredModelMBean exposes for management.
|
getNotificationInfo | back to summary |
---|---|
public MBeanNotificationInfo[] getNotificationInfo() Implements javax. Returns the array of Notifications always generated by the RequiredModelMBean. RequiredModelMBean may always send also two additional notifications:
|
hasNotification | back 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) |
invoke | back to summary |
---|---|
public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException Implements javax. 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:
Note because of inconsistencies in previous versions of
this specification, it is recommended not to use negative or zero
values for
|
invokeMethod | back to summary |
---|---|
private Object invokeMethod(String opName, final Method method, final Object targetObject, final Object[] opArgs) throws MBeanException, ReflectionException |
isRMMBMethodName | back to summary |
---|---|
private static synchronized boolean isRMMBMethodName(String name) |
load | back to summary |
---|---|
public void load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException Implements javax. 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
|
loadClass | back to summary |
---|---|
private Class |
makeAttributeChangeInfo | back to summary |
---|---|
private static final ModelMBeanNotificationInfo makeAttributeChangeInfo() Creates a default ModelMBeanNotificationInfo for ATTRIBUTE_CHANGE notification. (bug 4744667) |
makeGenericInfo | back to summary |
---|---|
private static final ModelMBeanNotificationInfo makeGenericInfo() Creates a default ModelMBeanNotificationInfo for GENERIC notification. (bug 4744667) |
postDeregister | back to summary |
---|---|
public void postDeregister() Implements javax. 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 |
postRegister | back to summary |
---|---|
public void postRegister(Boolean registrationDone) Implements javax. 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
|
preDeregister | back to summary |
---|---|
public void preDeregister() throws Exception Implements javax. 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
|
preRegister | back to summary |
---|---|
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception Implements javax. 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
|
printModelMBeanInfo | back to summary |
---|---|
private String printModelMBeanInfo(ModelMBeanInfo info) |
removeAttributeChangeNotificationListener | back to summary |
---|---|
public void removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException Implements javax. Removes a listener for attributeChangeNotifications from the RequiredModelMBean.
|
removeNotificationListener | back to summary |
---|---|
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException Implements javax. Removes a listener for Notifications from the RequiredModelMBean.
|
removeNotificationListener | back to summary |
---|---|
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException Implements javax. Doc from javax. Removes a listener from this MBean. The MBean must have a
listener that exactly matches the given The
|
resolveForCacheValue | back 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:
|
resolveMethod | back to summary |
---|---|
private Method resolveMethod(Class<?> targetClass, String opMethodName, final String[] sig) throws ReflectionException |
sendAttributeChangeNotification | back to summary |
---|---|
public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException Implements javax. Doc from javax. Sends an attributeChangeNotification which is passed in to the registered attributeChangeNotification listeners on the ModelMBean.
|
sendAttributeChangeNotification | back to summary |
---|---|
public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException Implements javax. Doc from javax. Sends an attributeChangeNotification which contains the old value and new value for the attribute to the registered AttributeChangeNotification listeners on the ModelMBean.
|
sendNotification | back to summary |
---|---|
public void sendNotification(Notification ntfyObj) throws MBeanException, RuntimeOperationsException Implements javax. Doc from javax. Sends a Notification which is passed in to the registered Notification listeners on the ModelMBean as a jmx.modelmbean.generic notification.
|
sendNotification | back to summary |
---|---|
public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException Implements javax. Doc from javax. Sends a Notification which contains the text string that is passed in to the registered Notification listeners on the ModelMBean.
|
setAttribute | back to summary |
---|---|
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException Implements javax. 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.
The ModelMBeanInfo of the Model MBean is stored in a file.
|
setAttributes | back to summary |
---|---|
public AttributeList setAttributes(AttributeList attributes) Implements javax. Sets the values of an array of attributes of this ModelMBean. Executes the setAttribute() method for each attribute in the list.
|
setManagedResource | back to summary |
---|---|
public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException Implements javax. Sets the instance handle of the object against which to execute all methods in this ModelMBean management interface (MBeanInfo and Descriptors).
|
setModelMBeanInfo | back to summary |
---|---|
public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException Implements javax. 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.
If the ModelMBean is currently registered, this method throws
a
If the given inModelMBeanInfo does not contain any
|
store | back to summary |
---|---|
public void store() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException Implements javax. 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 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'
|
writeToLog | back to summary |
---|---|
private synchronized void writeToLog(String logFileName, String logEntry) throws Exception |