|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.modeler.BaseModelMBean
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
.
Field Summary | |
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 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 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 Summary | |
BaseModelMBean()
Construct a ModelMBean with default
ModelMBeanInfo information. |
|
BaseModelMBean(ModelMBeanInfo info)
Construct a ModelMBean associated with the specified
ModelMBeanInfo information. |
|
BaseModelMBean(java.lang.String type,
ModelerSource source)
|
Method Summary | |
void |
addAttributeChangeNotificationListener(NotificationListener listener,
java.lang.String name,
java.lang.Object handback)
Add an attribute change notification event listener to this MBean. |
void |
addNotificationListener(NotificationListener listener,
NotificationFilter filter,
java.lang.Object handback)
Add a notification event listener to this MBean. |
protected 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)
|
AttributeList |
getAttributes(java.lang.String[] names)
Obtain and return the values of several attributes of this MBean. |
java.lang.String |
getClassName()
|
java.lang.Object |
getManagedResource()
Get the instance handle of the object against which we execute all methods in this ModelMBean management interface. |
MBeanInfo |
getMBeanInfo()
Return the MBeanInfo object for this MBean. |
java.lang.String |
getModelerType()
|
MBeanNotificationInfo[] |
getNotificationInfo()
Return an MBeanNotificationInfo object describing the
notifications sent by this MBean. |
ObjectName |
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(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()
|
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
|
void |
removeAttributeChangeNotificationListener(NotificationListener listener,
java.lang.String name)
Remove an attribute change notification event listener from this MBean. |
void |
removeAttributeChangeNotificationListener(NotificationListener listener,
java.lang.String attributeName,
java.lang.Object handback)
Remove an attribute change notification event listener from this MBean. |
void |
removeNotificationListener(NotificationListener listener)
Remove a notification event listener from this MBean. |
void |
removeNotificationListener(NotificationListener listener,
NotificationFilter filter,
java.lang.Object handback)
Remove a notification event listener from this MBean. |
void |
removeNotificationListener(NotificationListener listener,
java.lang.Object handback)
Remove a notification event listener from this MBean. |
void |
sendAttributeChangeNotification(Attribute oldValue,
Attribute newValue)
Send an AttributeChangeNotification to all registered
listeners. |
void |
sendAttributeChangeNotification(AttributeChangeNotification notification)
Send an AttributeChangeNotification to all registered
listeners. |
void |
sendNotification(Notification notification)
Send a Notification to all registered listeners as a
jmx.modelmbean.general notification. |
void |
setAttribute(Attribute attribute)
Set the value of a specific attribute of this MBean. |
AttributeList |
setAttributes(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(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()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static Log log
protected BaseNotificationBroadcaster attributeBroadcaster
protected Registry registry
protected BaseNotificationBroadcaster generalBroadcaster
protected ObjectName oname
protected 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
Constructor Detail |
public BaseModelMBean() throws MBeanException, RuntimeOperationsException
ModelMBean
with default
ModelMBeanInfo
information.
MBeanException
- if the initializer of an object
throws an exception
RuntimeOperationsException
- if an IllegalArgumentException
occurspublic BaseModelMBean(ModelMBeanInfo info) throws MBeanException, RuntimeOperationsException
ModelMBean
associated with the specified
ModelMBeanInfo
information.
info
- ModelMBeanInfo for this MBean
MBeanException
- if the initializer of an object
throws an exception
RuntimeOperationsException
- if an IllegalArgumentException
occurspublic BaseModelMBean(java.lang.String type, ModelerSource source) throws MBeanException, RuntimeOperationsException
Method Detail |
public java.lang.Object getAttribute(java.lang.String name) throws AttributeNotFoundException, MBeanException, ReflectionException
name
- Name of the requested attribute
AttributeNotFoundException
- if this attribute is not
supported by this MBean
MBeanException
- if the initializer of an object
throws an exception
ReflectionException
- if a Java reflection exception
occurs when invoking the getterpublic AttributeList getAttributes(java.lang.String[] names)
names
- Names of the requested attributespublic MBeanInfo getMBeanInfo()
MBeanInfo
object for this MBean.
public java.lang.Object invoke(java.lang.String name, java.lang.Object[] params, java.lang.String[] signature) throws MBeanException, 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.
name
- 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 operation
MBeanException
- if the initializer of an object
throws an exception
ReflectioNException
- if a Java reflection exception
occurs when invoking a method
ReflectionException
private java.lang.Class getAttributeClass(java.lang.String signature) throws ReflectionException
ReflectionException
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
attribute
- The identification of the attribute to be set
and the new value
AttributeNotFoundException
- if this attribute is not
supported by this MBean
MBeanException
- if the initializer of an object
throws an exception
ReflectionException
- if a Java reflection exception
occurs when invoking the getterpublic java.lang.String toString()
toString
in class java.lang.Object
public AttributeList setAttributes(AttributeList attributes)
attributes
- THe names and values to be set
public java.lang.Object getManagedResource() throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException
InstanceNotFoundException
- if the managed resource object
cannot be found
MBeanException
- if the initializer of the object throws
an exception
RuntimeOperationsException
- if the managed resource or the
resource type is null
or invalid
InvalidTargetObjectTypeException
public void setManagedResource(java.lang.Object resource, java.lang.String type) throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException
resource
- The resource object to be managedtype
- The type of reference for the managed resource
("ObjectReference", "Handle", "IOR", "EJBHandle", or
"RMIReference")
InstanceNotFoundException
- if the managed resource object
cannot be found
InvalidTargetObjectTypeException
- if this ModelMBean is
asked to handle a reference type it cannot deal with
MBeanException
- if the initializer of the object throws
an exception
RuntimeOperationsException
- if the managed resource or the
resource type is null
or invalidpublic void setModelMBeanInfo(ModelMBeanInfo info) throws MBeanException, 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.
info
- The ModelMBeanInfo object to be used by this ModelMBean
MBeanException
- If an exception occurs recording this
ModelMBeanInfo information
RuntimeOperations
- if the specified parameter is
null
or invalid
RuntimeOperationsException
public void addAttributeChangeNotificationListener(NotificationListener listener, java.lang.String name, java.lang.Object handback) throws java.lang.IllegalArgumentException
listener
- 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
notifications
java.lang.IllegalArgumentException
- if the listener parameter is nullpublic void removeAttributeChangeNotificationListener(NotificationListener listener, java.lang.String name) throws ListenerNotFoundException
listener
- The listener to be removedname
- The attribute name for which no more events are required
ListenerNotFoundException
- if this listener is not
registered in the MBeanpublic void removeAttributeChangeNotificationListener(NotificationListener listener, java.lang.String attributeName, java.lang.Object handback) throws 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
notifications
ListenerNotFoundException
- if this listener is not
registered in the MBeanpublic void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException
AttributeChangeNotification
to all registered
listeners.
notification
- The AttributeChangeNotification
that will be passed
MBeanException
- if an object initializer throws an
exception
RuntimeOperationsException
- wraps IllegalArgumentException
when the specified notification is null
or invalidpublic void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException
AttributeChangeNotification
to all registered
listeners.
oldValue
- The original value of the Attribute
newValue
- The new value of the Attribute
MBeanException
- if an object initializer throws an
exception
RuntimeOperationsException
- wraps IllegalArgumentException
when the specified notification is null
or invalidpublic void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException
Notification
to all registered listeners as a
jmx.modelmbean.general
notification.
notification
- The Notification
that will be passed
MBeanException
- if an object initializer throws an
exception
RuntimeOperationsException
- wraps IllegalArgumentException
when the specified notification is null
or invalidpublic void addNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback) throws java.lang.IllegalArgumentException
listener
- 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
notifications
java.lang.IllegalArgumentException
- if the listener parameter is nullpublic MBeanNotificationInfo[] getNotificationInfo()
MBeanNotificationInfo
object describing the
notifications sent by this MBean.
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
listener
- The listener to be removed (any and all registrations
for this listener will be eliminated)
ListenerNotFoundException
- if this listener is not
registered in the MBeanpublic void removeNotificationListener(NotificationListener listener, java.lang.Object handback) throws 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
notifications
ListenerNotFoundException
- if this listener is not
registered in the MBeanpublic void removeNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback) throws 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
notifications
ListenerNotFoundException
- if this listener is not
registered in the MBeanpublic void load() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException
MBeanServer
.
IMPLEMENTATION NOTE - This implementation does not support persistence.
InstanceNotFoundException
- if the managed resource object
cannot be found
MBeanException
- if the initializer of the object throws
an exception
RuntimeOperationsException
- if an exception is reported
by the persistence mechanismpublic void store() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException
IMPLEMENTATION NOTE - This implementation does not support persistence.
InstanceNotFoundException
- if the managed resource object
cannot be found
MBeanException
- if the initializer of the object throws
an exception, or persistence is not supported
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 ObjectName getObjectName()
public void setRegistry(Registry registry)
public Registry getRegistry()
protected ModelMBeanInfo createDefaultModelMBeanInfo()
ModelMBeanInfo
object.
protected boolean isModelMBeanInfoValid(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 check
public ObjectName preRegister(MBeanServer server, ObjectName name) throws java.lang.Exception
java.lang.Exception
public void postRegister(java.lang.Boolean registrationDone)
public void preDeregister() throws java.lang.Exception
java.lang.Exception
public void postDeregister()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |