| java.lang.Object org.apache.commons.modeler.BaseModelMBean
All known Subclasses: org.apache.commons.modeler.mbeans.MBeanProxy, org.apache.commons.modeler.JndiJmx,
BaseModelMBean | public class BaseModelMBean implements ModelMBean,MBeanRegistration(Code) | | 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:
- Only managed resources of type
objectReference are
supportd.
- Caching of attribute values and operation results is not supported.
All calls to
invoke() are immediately executed.
- Logging (under control of descriptors) is not supported.
- Persistence of MBean attributes and operations is not supported.
- All classes referenced as attribute types, operation parameters, or
operation return values must be one of the following:
- One of the Java primitive types (boolean, byte, char, double,
float, integer, long, short). Corresponding value will be wrapped
in the appropriate wrapper class automatically.
- Operations that return no value should declare a return type of
void .
- Attribute caching is not supported
author: Craig R. McClanahan author: Costin Manolache version: $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $ |
Inner Class :static class MethodKey | |
Method Summary | |
public void | addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) Add an attribute change notification event listener to this MBean. | public void | addNotificationListener(NotificationListener listener, NotificationFilter filter, 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. | public Object | getAttribute(String name) Obtain and return the value of a specific attribute of this MBean. | public AttributeList | getAttributes(String names) Obtain and return the values of several attributes of this MBean. | public String | getClassName() | public ObjectName | getJmxName() | public MBeanInfo | getMBeanInfo() Return the MBeanInfo object for this MBean. | public Object | getManagedResource() Get the instance handle of the object against which we execute
all methods in this ModelMBean management interface. | public String | getModelerType() | public MBeanNotificationInfo[] | getNotificationInfo() Return an MBeanNotificationInfo object describing the
notifications sent by this MBean. | public String | getObjectName() | public Registry | getRegistry() | protected void | initModelInfo(String type) Set the type of the mbean. | public Object | invoke(String name, Object params, String signature) Invoke a particular method on this MBean, and return any returned
value. | protected boolean | isModelMBeanInfoValid(ModelMBeanInfo info) | public void | load() Instantiates this MBean instance from data found in the persistent
store. | public void | postDeregister() | public void | postRegister(Boolean registrationDone) | public void | preDeregister() | public ObjectName | preRegister(MBeanServer server, ObjectName name) | public void | removeAttributeChangeNotificationListener(NotificationListener listener, String name) Remove an attribute change notification event listener from
this MBean. | public void | removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) Remove an attribute change notification event listener from
this MBean. | public void | removeNotificationListener(NotificationListener listener) Remove a notification event listener from this MBean. | public void | removeNotificationListener(NotificationListener listener, Object handback) Remove a notification event listener from this MBean. | public void | removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) Remove a notification event listener from this MBean. | public void | sendAttributeChangeNotification(AttributeChangeNotification notification) Send an AttributeChangeNotification to all registered
listeners. | public void | sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) Send an AttributeChangeNotification to all registered
listeners. | public void | sendNotification(Notification notification) Send a Notification to all registered listeners as a
jmx.modelmbean.general notification. | public void | sendNotification(String message) Send a Notification which contains the specified string
as a jmx.modelmbean.generic notification. | public void | setAttribute(Attribute attribute) Set the value of a specific attribute of this MBean. | public AttributeList | setAttributes(AttributeList attributes) Set the values of several attributes of this MBean. | public void | setManagedResource(Object resource, String type) Set the instance handle of the object against which we will execute
all methods in this ModelMBean management interface.
This method will detect and call "setModelMbean" method. | public void | setModelMBeanInfo(ModelMBeanInfo info) Initialize the ModelMBeanInfo associated with this
ModelMBean . | public void | setModeledType(String type) Set the type of the mbean. | public void | setRegistry(Registry registry) | public void | store() Capture the current state of this MBean instance and write it out
to the persistent store. | public String | toString() |
NO_ARGS_PARAM_SIG | final static Class[] NO_ARGS_PARAM_SIG(Code) | | |
attributes | protected HashMap attributes(Code) | | Attribute values. XXX That can be stored in the value Field
|
registry | protected Registry registry(Code) | | Registry we are associated with
|
resource | protected Object resource(Code) | | The managed resource this MBean is associated with (if any).
|
source | protected ModelerSource source(Code) | | Source object used to read this mbean. Can be used to
persist the mbean
|
BaseModelMBean | public BaseModelMBean(String type) throws MBeanException, RuntimeOperationsException(Code) | | Construct a ModelMBean of a specified type.
The type can be a class name or the key used in one of the descriptors.
If no descriptor is available, we'll first try to locate one in
the same package with the class, then use introspection.
The mbean resource will be created.
Parameters: type - Class name or the type key used in the descriptor. throws: MBeanException - throws: RuntimeOperationsException - |
addAttributeChangeNotificationListener | public void addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) throws IllegalArgumentException(Code) | | Add an attribute change notification event listener to this MBean.
Parameters: listener - Listener that will receive event notifications Parameters: name - Name of the attribute of interest, or null to indicate interest in all attributes Parameters: handback - Handback object to be sent along with eventnotifications exception: IllegalArgumentException - if the listener parameter is null |
addNotificationListener | public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException(Code) | | Add a notification event listener to this MBean.
Parameters: listener - Listener that will receive event notifications Parameters: filter - Filter object used to filter event notificationsactually delivered, or null for no filtering Parameters: handback - Handback object to be sent along with eventnotifications exception: IllegalArgumentException - if the listener parameter is null |
createDefaultModelMBeanInfo | protected ModelMBeanInfo createDefaultModelMBeanInfo()(Code) | | Create and return a default ModelMBeanInfo object.
|
createResource | protected void createResource()(Code) | | Set the type of the mbean. This is used as a key to locate
the description in the Registry.
|
getAttributes | public AttributeList getAttributes(String names)(Code) | | Obtain and return the values of several attributes of this MBean.
Parameters: names - Names of the requested attributes |
getMBeanInfo | public MBeanInfo getMBeanInfo()(Code) | | Return the MBeanInfo object for this MBean.
|
getNotificationInfo | public MBeanNotificationInfo[] getNotificationInfo()(Code) | | Return an MBeanNotificationInfo object describing the
notifications sent by this MBean.
|
initModelInfo | protected void initModelInfo(String type)(Code) | | Set the type of the mbean. This is used as a key to locate
the description in the Registry.
Parameters: type - the type of classname of the modeled object |
invoke | public Object invoke(String name, Object params, String signature) throws MBeanException, ReflectionException(Code) | | Invoke a particular method on this MBean, and return any returned
value.
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.
Parameters: name - Name of the operation to be invoked Parameters: params - Array containing the method parameters of this operation Parameters: signature - Array containing the class names representingthe signature of this operation exception: MBeanException - if the initializer of an objectthrows an exception exception: ReflectioNException - if a Java reflection exceptionoccurs when invoking a method |
isModelMBeanInfoValid | protected boolean isModelMBeanInfoValid(ModelMBeanInfo info)(Code) | | Is the specified ModelMBeanInfo instance valid?
IMPLEMENTATION NOTE - This implementation
does not check anything, but this method can be overridden
as required.
Parameters: info - The ModelMBeanInfo object to check |
load | public void load() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException(Code) | | Instantiates this MBean instance from data found in the persistent
store. The data loaded could include attribute and operation values.
This method should be called during construction or initialization
of the instance, and before the MBean is registered with the
MBeanServer .
IMPLEMENTATION NOTE - This implementation does
not support persistence.
exception: InstanceNotFoundException - if the managed resource objectcannot be found exception: MBeanException - if the initializer of the object throwsan exception exception: RuntimeOperationsException - if an exception is reportedby the persistence mechanism |
postDeregister | public void postDeregister()(Code) | | |
postRegister | public void postRegister(Boolean registrationDone)(Code) | | |
removeAttributeChangeNotificationListener | public void removeAttributeChangeNotificationListener(NotificationListener listener, String name) throws ListenerNotFoundException(Code) | | Remove an attribute change notification event listener from
this MBean.
Parameters: listener - The listener to be removed Parameters: name - The attribute name for which no more events are required exception: ListenerNotFoundException - if this listener is notregistered in the MBean |
removeAttributeChangeNotificationListener | public void removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws ListenerNotFoundException(Code) | | Remove an attribute change notification event listener from
this MBean.
Parameters: listener - The listener to be removed Parameters: attributeName - The attribute name for which no more events are required Parameters: handback - Handback object to be sent along with eventnotifications exception: ListenerNotFoundException - if this listener is notregistered in the MBean |
removeNotificationListener | public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException(Code) | | Remove a notification event listener from this MBean.
Parameters: listener - The listener to be removed (any and all registrationsfor this listener will be eliminated) exception: ListenerNotFoundException - if this listener is notregistered in the MBean |
removeNotificationListener | public void removeNotificationListener(NotificationListener listener, Object handback) throws ListenerNotFoundException(Code) | | Remove a notification event listener from this MBean.
Parameters: listener - The listener to be removed (any and all registrationsfor this listener will be eliminated) Parameters: handback - Handback object to be sent along with eventnotifications exception: ListenerNotFoundException - if this listener is notregistered in the MBean |
removeNotificationListener | public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException(Code) | | Remove a notification event listener from this MBean.
Parameters: listener - The listener to be removed (any and all registrationsfor this listener will be eliminated) Parameters: filter - Filter object used to filter event notificationsactually delivered, or null for no filtering Parameters: handback - Handback object to be sent along with eventnotifications exception: ListenerNotFoundException - if this listener is notregistered in the MBean |
sendAttributeChangeNotification | public void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException(Code) | | Send an AttributeChangeNotification to all registered
listeners.
Parameters: oldValue - The original value of the Attribute Parameters: newValue - The new value of the Attribute exception: MBeanException - if an object initializer throws anexception exception: RuntimeOperationsException - wraps IllegalArgumentExceptionwhen the specified notification is null or invalid |
setAttributes | public AttributeList setAttributes(AttributeList attributes)(Code) | | Set the values of several attributes of this MBean.
Parameters: attributes - THe names and values to be set The list of attributes that were set and their new values |
setManagedResource | public void setManagedResource(Object resource, String type) throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException(Code) | | Set the instance handle of the object against which we will execute
all methods in this ModelMBean management interface.
This method will detect and call "setModelMbean" method. A resource
can implement this method to get a reference to the model mbean.
The reference can be used to send notification and access the
registry.
Parameters: resource - The resource object to be managed Parameters: type - The type of reference for the managed resource("ObjectReference", "Handle", "IOR", "EJBHandle", or"RMIReference") exception: InstanceNotFoundException - if the managed resource objectcannot be found exception: InvalidTargetObjectTypeException - if this ModelMBean isasked to handle a reference type it cannot deal with exception: MBeanException - if the initializer of the object throwsan exception exception: RuntimeOperationsException - if the managed resource or theresource type is null or invalid |
setModelMBeanInfo | public void setModelMBeanInfo(ModelMBeanInfo info) throws MBeanException, RuntimeOperationsException(Code) | | Initialize the 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.
Parameters: info - The ModelMBeanInfo object to be used by this ModelMBean exception: MBeanException - If an exception occurs recording thisModelMBeanInfo information exception: RuntimeOperations - if the specified parameter isnull or invalid |
setModeledType | public void setModeledType(String type)(Code) | | Set the type of the mbean. This is used as a key to locate
the description in the Registry.
Parameters: type - the type of classname of the modeled object |
store | public void store() throws InstanceNotFoundException, MBeanException, RuntimeOperationsException(Code) | | Capture the current state of this MBean instance and write it out
to the persistent store. The state stored could include attribute
and operation values. If one of these methods of persistence is not
supported, a "service not found" exception will be thrown.
IMPLEMENTATION NOTE - This implementation does
not support persistence.
exception: InstanceNotFoundException - if the managed resource objectcannot be found exception: MBeanException - if the initializer of the object throwsan exception, or persistence is not supported exception: RuntimeOperationsException - if an exception is reportedby the persistence mechanism |
|
|