Save This Page
Home » commons-modeler-2.0.1-src » org.apache.commons » modeler » [javadoc | source]
org.apache.commons.modeler
public class: BaseModelMBean [javadoc | source]
java.lang.Object
   org.apache.commons.modeler.BaseModelMBean

All Implemented Interfaces:
    ModelMBean, MBeanRegistration

Direct Known Subclasses:
    JndiJmx, MBeanProxy

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:

Nested Class Summary:
static class  BaseModelMBean.MethodKey   
Field Summary
protected  BaseNotificationBroadcaster attributeBroadcaster    Notification broadcaster for attribute changes. 
protected  Registry registry    Registry we are associated with 
protected  BaseNotificationBroadcaster generalBroadcaster    Notification broadcaster for general notifications. 
protected  ObjectName oname     
protected  ModelMBeanInfo info    The ModelMBeanInfo object that controls our activity. 
protected  Object resource    The managed resource this MBean is associated with (if any). 
protected  String resourceType     
protected  ModelerSource source    Source object used to read this mbean. Can be used to persist the mbean 
protected  HashMap attributes    Attribute values. XXX That can be stored in the value Field 
static final  Object[] NO_ARGS_PARAM     
static final  Class[] NO_ARGS_PARAM_SIG     
Constructor:
 public BaseModelMBean() throws RuntimeOperationsException, MBeanException 
    Construct a ModelMBean with default ModelMBeanInfo information.
    Throws:
    MBeanException - if the initializer of an object throws an exception
    RuntimeOperationsException - if an IllegalArgumentException occurs
    exception: MBeanException - if the initializer of an object throws an exception
    exception: RuntimeOperationsException - if an IllegalArgumentException occurs
 public BaseModelMBean(ModelMBeanInfo info) throws RuntimeOperationsException, MBeanException 
    Construct a ModelMBean associated with the specified ModelMBeanInfo information.
    Parameters:
    info - ModelMBeanInfo for this MBean
    Throws:
    MBeanException - if the initializer of an object throws an exception
    RuntimeOperationsException - if an IllegalArgumentException occurs
    exception: MBeanException - if the initializer of an object throws an exception
    exception: RuntimeOperationsException - if an IllegalArgumentException occurs
 public BaseModelMBean(String type) throws RuntimeOperationsException, MBeanException 
    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 -
    RuntimeOperationsException -
 public BaseModelMBean(String type,
    ModelerSource source) throws RuntimeOperationsException, MBeanException 
Method from org.apache.commons.modeler.BaseModelMBean Summary:
addAttributeChangeNotificationListener,   addNotificationListener,   createDefaultModelMBeanInfo,   createResource,   getAttribute,   getAttributes,   getClassName,   getJmxName,   getMBeanInfo,   getManagedResource,   getModelerType,   getNotificationInfo,   getObjectName,   getRegistry,   initModelInfo,   invoke,   isModelMBeanInfoValid,   load,   postDeregister,   postRegister,   preDeregister,   preRegister,   removeAttributeChangeNotificationListener,   removeAttributeChangeNotificationListener,   removeNotificationListener,   removeNotificationListener,   removeNotificationListener,   sendAttributeChangeNotification,   sendAttributeChangeNotification,   sendNotification,   sendNotification,   setAttribute,   setAttributes,   setManagedResource,   setModelMBeanInfo,   setModeledType,   setRegistry,   store,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.modeler.BaseModelMBean Detail:
 public  void addAttributeChangeNotificationListener(NotificationListener listener,
    String name,
    Object handback) throws IllegalArgumentException 
    Add an attribute change notification event listener to this MBean.
 public  void addNotificationListener(NotificationListener listener,
    NotificationFilter filter,
    Object handback) throws IllegalArgumentException 
    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. This is used as a key to locate the description in the Registry.
 public Object getAttribute(String name) throws ReflectionException, AttributeNotFoundException, MBeanException 
    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() throws InstanceNotFoundException, InvalidTargetObjectTypeException, RuntimeOperationsException, MBeanException 
    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. This is used as a key to locate the description in the Registry.
 public Object invoke(String name,
    Object[] params,
    String[] signature) throws ReflectionException, MBeanException 
    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.

 protected boolean isModelMBeanInfoValid(ModelMBeanInfo info) 
    Is the specified ModelMBeanInfo instance valid?

    IMPLEMENTATION NOTE - This implementation does not check anything, but this method can be overridden as required.

 public  void load() throws InstanceNotFoundException, RuntimeOperationsException, MBeanException 
    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.

 public  void postDeregister() 
 public  void postRegister(Boolean registrationDone) 
 public  void preDeregister() throws Exception 
 public ObjectName preRegister(MBeanServer server,
    ObjectName name) throws Exception 
 public  void removeAttributeChangeNotificationListener(NotificationListener listener,
    String name) throws ListenerNotFoundException 
    Remove an attribute change notification event listener from this MBean.
 public  void removeAttributeChangeNotificationListener(NotificationListener listener,
    String attributeName,
    Object handback) throws ListenerNotFoundException 
    Remove an attribute change notification event listener from this MBean.
 public  void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException 
    Remove a notification event listener from this MBean.
 public  void removeNotificationListener(NotificationListener listener,
    Object handback) throws ListenerNotFoundException 
    Remove a notification event listener from this MBean.
 public  void removeNotificationListener(NotificationListener listener,
    NotificationFilter filter,
    Object handback) throws ListenerNotFoundException 
    Remove a notification event listener from this MBean.
 public  void sendAttributeChangeNotification(AttributeChangeNotification notification) throws RuntimeOperationsException, MBeanException 
    Send an AttributeChangeNotification to all registered listeners.
 public  void sendAttributeChangeNotification(Attribute oldValue,
    Attribute newValue) throws RuntimeOperationsException, MBeanException 
    Send an AttributeChangeNotification to all registered listeners.
 public  void sendNotification(Notification notification) throws RuntimeOperationsException, MBeanException 
    Send a Notification to all registered listeners as a jmx.modelmbean.general notification.
 public  void sendNotification(String message) throws RuntimeOperationsException, MBeanException 
    Send a Notification which contains the specified string as a jmx.modelmbean.generic notification.
 public  void setAttribute(Attribute attribute) throws ReflectionException, AttributeNotFoundException, MBeanException 
    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) throws InstanceNotFoundException, InvalidTargetObjectTypeException, RuntimeOperationsException, MBeanException 
    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.
 public  void setModelMBeanInfo(ModelMBeanInfo info) throws RuntimeOperationsException, MBeanException 
    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.
 public  void setModeledType(String type) 
    Set the type of the mbean. This is used as a key to locate the description in the Registry.
 public  void setRegistry(Registry registry) 
 public  void store() throws InstanceNotFoundException, RuntimeOperationsException, MBeanException 
    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.

 public String toString()