public class BaseModelMBean
extends java.lang.Object
implements javax.management.modelmbean.ModelMBean, javax.management.MBeanRegistration
Basic implementation of the ModelMBean interface, which
supports the minimal requirements of the interface contract.
This can be used directly to wrap an existing java bean, or inside an mlet or anywhere an MBean would be used. The String parameter passed to the constructor will be used to construct an instance of the real object that we wrap. Limitations:
objectReference are
supportd.invoke() are immediately executed.void.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
BaseModelMBean.MethodKey |
| Modifier and Type | Field and Description |
|---|---|
protected BaseNotificationBroadcaster |
attributeBroadcaster
Notification broadcaster for attribute changes.
|
protected java.util.HashMap |
attributes
Attribute values.
|
protected BaseNotificationBroadcaster |
generalBroadcaster
Notification broadcaster for general notifications.
|
private java.util.Hashtable |
getAttMap |
protected javax.management.modelmbean.ModelMBeanInfo |
info
The
ModelMBeanInfo object that controls our activity. |
private java.util.Hashtable |
invokeAttMap |
private static Log |
log |
(package private) static java.lang.Object[] |
NO_ARGS_PARAM |
(package private) static java.lang.Class[] |
NO_ARGS_PARAM_SIG |
protected javax.management.ObjectName |
oname |
protected Registry |
registry
Registry we are associated with
|
protected java.lang.Object |
resource
The managed resource this MBean is associated with (if any).
|
protected java.lang.String |
resourceType |
private java.util.Hashtable |
setAttMap |
protected ModelerSource |
source
Source object used to read this mbean.
|
| Constructor and Description |
|---|
BaseModelMBean()
Construct a
ModelMBean with default
ModelMBeanInfo information. |
BaseModelMBean(javax.management.modelmbean.ModelMBeanInfo info)
Construct a
ModelMBean associated with the specified
ModelMBeanInfo information. |
BaseModelMBean(java.lang.String type)
Construct a ModelMBean of a specified type.
|
BaseModelMBean(java.lang.String type,
ModelerSource source) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttributeChangeNotificationListener(javax.management.NotificationListener listener,
java.lang.String name,
java.lang.Object handback)
Add an attribute change notification event listener to this MBean.
|
void |
addNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object handback)
Add a notification event listener to this MBean.
|
protected javax.management.modelmbean.ModelMBeanInfo |
createDefaultModelMBeanInfo()
Create and return a default
ModelMBeanInfo object. |
protected void |
createResource()
Set the type of the mbean.
|
java.lang.Object |
getAttribute(java.lang.String name)
Obtain and return the value of a specific attribute of this MBean.
|
private java.lang.Class |
getAttributeClass(java.lang.String signature) |
javax.management.AttributeList |
getAttributes(java.lang.String[] names)
Obtain and return the values of several attributes of this MBean.
|
java.lang.String |
getClassName() |
javax.management.ObjectName |
getJmxName() |
java.lang.Object |
getManagedResource()
Get the instance handle of the object against which we execute
all methods in this ModelMBean management interface.
|
javax.management.MBeanInfo |
getMBeanInfo()
Return the
MBeanInfo object for this MBean. |
java.lang.String |
getModelerType() |
javax.management.MBeanNotificationInfo[] |
getNotificationInfo()
Return an
MBeanNotificationInfo object describing the
notifications sent by this MBean. |
java.lang.String |
getObjectName() |
Registry |
getRegistry() |
protected void |
initModelInfo(java.lang.String type)
Set the type of the mbean.
|
java.lang.Object |
invoke(java.lang.String name,
java.lang.Object[] params,
java.lang.String[] signature)
Invoke a particular method on this MBean, and return any returned
value.
|
protected boolean |
isModelMBeanInfoValid(javax.management.modelmbean.ModelMBeanInfo info)
Is the specified
ModelMBeanInfo instance valid? |
void |
load()
Instantiates this MBean instance from data found in the persistent
store.
|
void |
postDeregister() |
void |
postRegister(java.lang.Boolean registrationDone) |
void |
preDeregister() |
javax.management.ObjectName |
preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name) |
void |
removeAttributeChangeNotificationListener(javax.management.NotificationListener listener,
java.lang.String name)
Remove an attribute change notification event listener from
this MBean.
|
void |
removeAttributeChangeNotificationListener(javax.management.NotificationListener listener,
java.lang.String attributeName,
java.lang.Object handback)
Remove an attribute change notification event listener from
this MBean.
|
void |
removeNotificationListener(javax.management.NotificationListener listener)
Remove a notification event listener from this MBean.
|
void |
removeNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object handback)
Remove a notification event listener from this MBean.
|
void |
removeNotificationListener(javax.management.NotificationListener listener,
java.lang.Object handback)
Remove a notification event listener from this MBean.
|
void |
sendAttributeChangeNotification(javax.management.Attribute oldValue,
javax.management.Attribute newValue)
Send an
AttributeChangeNotification to all registered
listeners. |
void |
sendAttributeChangeNotification(javax.management.AttributeChangeNotification notification)
Send an
AttributeChangeNotification to all registered
listeners. |
void |
sendNotification(javax.management.Notification notification)
Send a
Notification to all registered listeners as a
jmx.modelmbean.general notification. |
void |
sendNotification(java.lang.String message)
Send a
Notification which contains the specified string
as a jmx.modelmbean.generic notification. |
void |
setAttribute(javax.management.Attribute attribute)
Set the value of a specific attribute of this MBean.
|
javax.management.AttributeList |
setAttributes(javax.management.AttributeList attributes)
Set the values of several attributes of this MBean.
|
void |
setManagedResource(java.lang.Object resource,
java.lang.String type)
Set the instance handle of the object against which we will execute
all methods in this ModelMBean management interface.
|
void |
setModeledType(java.lang.String type)
Set the type of the mbean.
|
void |
setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo info)
Initialize the
ModelMBeanInfo associated with this
ModelMBean. |
void |
setRegistry(Registry registry) |
void |
store()
Capture the current state of this MBean instance and write it out
to the persistent store.
|
java.lang.String |
toString() |
private static Log log
protected BaseNotificationBroadcaster attributeBroadcaster
protected Registry registry
protected BaseNotificationBroadcaster generalBroadcaster
protected javax.management.ObjectName oname
protected javax.management.modelmbean.ModelMBeanInfo info
ModelMBeanInfo object that controls our activity.protected java.lang.Object resource
protected java.lang.String resourceType
protected ModelerSource source
protected java.util.HashMap attributes
static final java.lang.Object[] NO_ARGS_PARAM
static final java.lang.Class[] NO_ARGS_PARAM_SIG
private java.util.Hashtable getAttMap
private java.util.Hashtable setAttMap
private java.util.Hashtable invokeAttMap
public BaseModelMBean()
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
ModelMBean with default
ModelMBeanInfo information.javax.management.MBeanException - if the initializer of an object
throws an exceptionjavax.management.RuntimeOperationsException - if an IllegalArgumentException
occurspublic BaseModelMBean(javax.management.modelmbean.ModelMBeanInfo info)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
ModelMBean associated with the specified
ModelMBeanInfo information.info - ModelMBeanInfo for this MBeanjavax.management.MBeanException - if the initializer of an object
throws an exceptionjavax.management.RuntimeOperationsException - if an IllegalArgumentException
occurspublic BaseModelMBean(java.lang.String type)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
type - Class name or the type key used in the descriptor.javax.management.MBeanExceptionjavax.management.RuntimeOperationsExceptionpublic BaseModelMBean(java.lang.String type,
ModelerSource source)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
javax.management.MBeanExceptionjavax.management.RuntimeOperationsExceptionpublic java.lang.Object getAttribute(java.lang.String name)
throws javax.management.AttributeNotFoundException,
javax.management.MBeanException,
javax.management.ReflectionException
getAttribute in interface javax.management.DynamicMBeanname - Name of the requested attributejavax.management.AttributeNotFoundException - if this attribute is not
supported by this MBeanjavax.management.MBeanException - if the initializer of an object
throws an exceptionjavax.management.ReflectionException - if a Java reflection exception
occurs when invoking the getterpublic javax.management.AttributeList getAttributes(java.lang.String[] names)
getAttributes in interface javax.management.DynamicMBeannames - Names of the requested attributespublic javax.management.MBeanInfo getMBeanInfo()
MBeanInfo object for this MBean.getMBeanInfo in interface javax.management.DynamicMBeanpublic java.lang.Object invoke(java.lang.String name,
java.lang.Object[] params,
java.lang.String[] signature)
throws javax.management.MBeanException,
javax.management.ReflectionException
IMPLEMENTATION NOTE - This implementation will attempt to invoke this method on the MBean itself, or (if not available) on the managed resource object associated with this MBean.
invoke in interface javax.management.DynamicMBeanname - Name of the operation to be invokedparams - Array containing the method parameters of this operationsignature - Array containing the class names representing
the signature of this operationjavax.management.MBeanException - if the initializer of an object
throws an exceptionReflectioNException - if a Java reflection exception
occurs when invoking a methodjavax.management.ReflectionExceptionprivate java.lang.Class getAttributeClass(java.lang.String signature)
throws javax.management.ReflectionException
javax.management.ReflectionExceptionpublic void setAttribute(javax.management.Attribute attribute)
throws javax.management.AttributeNotFoundException,
javax.management.MBeanException,
javax.management.ReflectionException
setAttribute in interface javax.management.DynamicMBeanattribute - The identification of the attribute to be set
and the new valuejavax.management.AttributeNotFoundException - if this attribute is not
supported by this MBeanjavax.management.MBeanException - if the initializer of an object
throws an exceptionjavax.management.ReflectionException - if a Java reflection exception
occurs when invoking the getterpublic java.lang.String toString()
toString in class java.lang.Objectpublic javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
setAttributes in interface javax.management.DynamicMBeanattributes - THe names and values to be setpublic java.lang.Object getManagedResource()
throws javax.management.InstanceNotFoundException,
javax.management.modelmbean.InvalidTargetObjectTypeException,
javax.management.MBeanException,
javax.management.RuntimeOperationsException
javax.management.InstanceNotFoundException - if the managed resource object
cannot be foundjavax.management.MBeanException - if the initializer of the object throws
an exceptionjavax.management.RuntimeOperationsException - if the managed resource or the
resource type is null or invalidjavax.management.modelmbean.InvalidTargetObjectTypeExceptionpublic void setManagedResource(java.lang.Object resource,
java.lang.String type)
throws javax.management.InstanceNotFoundException,
javax.management.modelmbean.InvalidTargetObjectTypeException,
javax.management.MBeanException,
javax.management.RuntimeOperationsException
setManagedResource in interface javax.management.modelmbean.ModelMBeanresource - The resource object to be managedtype - The type of reference for the managed resource
("ObjectReference", "Handle", "IOR", "EJBHandle", or
"RMIReference")javax.management.InstanceNotFoundException - if the managed resource object
cannot be foundjavax.management.modelmbean.InvalidTargetObjectTypeException - if this ModelMBean is
asked to handle a reference type it cannot deal withjavax.management.MBeanException - if the initializer of the object throws
an exceptionjavax.management.RuntimeOperationsException - if the managed resource or the
resource type is null or invalidpublic void setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo info)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
ModelMBeanInfo associated with this
ModelMBean. After the information and associated
descriptors have been customized, the ModelMBean should
be registered with the associated MBeanServer.
Currently the model can be set after registration. This behavior is
deprecated and won't be supported in future versions.setModelMBeanInfo in interface javax.management.modelmbean.ModelMBeaninfo - The ModelMBeanInfo object to be used by this ModelMBeanjavax.management.MBeanException - If an exception occurs recording this
ModelMBeanInfo informationRuntimeOperations - if the specified parameter is
null or invalidjavax.management.RuntimeOperationsExceptionpublic void addAttributeChangeNotificationListener(javax.management.NotificationListener listener,
java.lang.String name,
java.lang.Object handback)
throws java.lang.IllegalArgumentException
addAttributeChangeNotificationListener in interface javax.management.modelmbean.ModelMBeanNotificationBroadcasterlistener - Listener that will receive event notificationsname - Name of the attribute of interest, or null
to indicate interest in all attributeshandback - Handback object to be sent along with event
notificationsjava.lang.IllegalArgumentException - if the listener parameter is nullpublic void removeAttributeChangeNotificationListener(javax.management.NotificationListener listener,
java.lang.String name)
throws javax.management.ListenerNotFoundException
removeAttributeChangeNotificationListener in interface javax.management.modelmbean.ModelMBeanNotificationBroadcasterlistener - The listener to be removedname - The attribute name for which no more events are requiredjavax.management.ListenerNotFoundException - if this listener is not
registered in the MBeanpublic void removeAttributeChangeNotificationListener(javax.management.NotificationListener listener,
java.lang.String attributeName,
java.lang.Object handback)
throws javax.management.ListenerNotFoundException
listener - The listener to be removedattributeName - The attribute name for which no more events are requiredhandback - Handback object to be sent along with event
notificationsjavax.management.ListenerNotFoundException - if this listener is not
registered in the MBeanpublic void sendAttributeChangeNotification(javax.management.AttributeChangeNotification notification)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
AttributeChangeNotification to all registered
listeners.sendAttributeChangeNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcasternotification - The AttributeChangeNotification
that will be passedjavax.management.MBeanException - if an object initializer throws an
exceptionjavax.management.RuntimeOperationsException - wraps IllegalArgumentException
when the specified notification is null or invalidpublic void sendAttributeChangeNotification(javax.management.Attribute oldValue,
javax.management.Attribute newValue)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
AttributeChangeNotification to all registered
listeners.sendAttributeChangeNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcasteroldValue - The original value of the AttributenewValue - The new value of the Attributejavax.management.MBeanException - if an object initializer throws an
exceptionjavax.management.RuntimeOperationsException - wraps IllegalArgumentException
when the specified notification is null or invalidpublic void sendNotification(javax.management.Notification notification)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
Notification to all registered listeners as a
jmx.modelmbean.general notification.sendNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcasternotification - The Notification that will be passedjavax.management.MBeanException - if an object initializer throws an
exceptionjavax.management.RuntimeOperationsException - wraps IllegalArgumentException
when the specified notification is null or invalidpublic void sendNotification(java.lang.String message)
throws javax.management.MBeanException,
javax.management.RuntimeOperationsException
Notification which contains the specified string
as a jmx.modelmbean.generic notification.sendNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcastermessage - The message string to be passedjavax.management.MBeanException - if an object initializer throws an
exceptionjavax.management.RuntimeOperationsException - wraps IllegalArgumentException
when the specified notification is null or invalidpublic void addNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object handback)
throws java.lang.IllegalArgumentException
addNotificationListener in interface javax.management.NotificationBroadcasterlistener - Listener that will receive event notificationsfilter - Filter object used to filter event notifications
actually delivered, or null for no filteringhandback - Handback object to be sent along with event
notificationsjava.lang.IllegalArgumentException - if the listener parameter is nullpublic javax.management.MBeanNotificationInfo[] getNotificationInfo()
MBeanNotificationInfo object describing the
notifications sent by this MBean.getNotificationInfo in interface javax.management.NotificationBroadcasterpublic void removeNotificationListener(javax.management.NotificationListener listener)
throws javax.management.ListenerNotFoundException
removeNotificationListener in interface javax.management.NotificationBroadcasterlistener - The listener to be removed (any and all registrations
for this listener will be eliminated)javax.management.ListenerNotFoundException - if this listener is not
registered in the MBeanpublic void removeNotificationListener(javax.management.NotificationListener listener,
java.lang.Object handback)
throws javax.management.ListenerNotFoundException
listener - The listener to be removed (any and all registrations
for this listener will be eliminated)handback - Handback object to be sent along with event
notificationsjavax.management.ListenerNotFoundException - if this listener is not
registered in the MBeanpublic void removeNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object handback)
throws javax.management.ListenerNotFoundException
listener - The listener to be removed (any and all registrations
for this listener will be eliminated)filter - Filter object used to filter event notifications
actually delivered, or null for no filteringhandback - Handback object to be sent along with event
notificationsjavax.management.ListenerNotFoundException - if this listener is not
registered in the MBeanpublic void load()
throws javax.management.InstanceNotFoundException,
javax.management.MBeanException,
javax.management.RuntimeOperationsException
MBeanServer.
IMPLEMENTATION NOTE - This implementation does not support persistence.
load in interface javax.management.PersistentMBeanjavax.management.InstanceNotFoundException - if the managed resource object
cannot be foundjavax.management.MBeanException - if the initializer of the object throws
an exceptionjavax.management.RuntimeOperationsException - if an exception is reported
by the persistence mechanismpublic void store()
throws javax.management.InstanceNotFoundException,
javax.management.MBeanException,
javax.management.RuntimeOperationsException
IMPLEMENTATION NOTE - This implementation does not support persistence.
store in interface javax.management.PersistentMBeanjavax.management.InstanceNotFoundException - if the managed resource object
cannot be foundjavax.management.MBeanException - if the initializer of the object throws
an exception, or persistence is not supportedjavax.management.RuntimeOperationsException - if an exception is reported
by the persistence mechanismpublic void setModeledType(java.lang.String type)
type - the type of classname of the modeled objectprotected void initModelInfo(java.lang.String type)
type - the type of classname of the modeled objectprotected void createResource()
public java.lang.String getModelerType()
public java.lang.String getClassName()
public javax.management.ObjectName getJmxName()
public java.lang.String getObjectName()
public void setRegistry(Registry registry)
public Registry getRegistry()
protected javax.management.modelmbean.ModelMBeanInfo createDefaultModelMBeanInfo()
ModelMBeanInfo object.protected boolean isModelMBeanInfoValid(javax.management.modelmbean.ModelMBeanInfo info)
ModelMBeanInfo instance valid?
IMPLEMENTATION NOTE - This implementation does not check anything, but this method can be overridden as required.
info - The ModelMBeanInfo object to checkpublic javax.management.ObjectName preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
throws java.lang.Exception
preRegister in interface javax.management.MBeanRegistrationjava.lang.Exceptionpublic void postRegister(java.lang.Boolean registrationDone)
postRegister in interface javax.management.MBeanRegistrationpublic void preDeregister()
throws java.lang.Exception
preDeregister in interface javax.management.MBeanRegistrationjava.lang.Exceptionpublic void postDeregister()
postDeregister in interface javax.management.MBeanRegistrationCopyright (c) 2001-2003 - Apache Software Foundation