Package org.apache.tomcat.util.modeler
Class BaseModelMBean
java.lang.Object
org.apache.tomcat.util.modeler.BaseModelMBean
- All Implemented Interfaces:
- DynamicMBean,- MBeanRegistration,- ModelMBeanNotificationBroadcaster,- NotificationBroadcaster
- Direct Known Subclasses:
- BaseCatalinaMBean,- DataSourceUserDatabaseMBean,- GroupMBean,- NamingResourcesMBean,- RequestGroupInfo,- RoleMBean,- SparseUserDatabaseMBean,- UpgradeGroupInfo,- UserMBean
public class BaseModelMBean
extends Object
implements DynamicMBean, MBeanRegistration, ModelMBeanNotificationBroadcaster
Basic implementation of the DynamicMBean 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. Limitations:
- Only managed resources of type objectReferenceare supported.
- Caching of attribute values and operation results is not supported.
     All calls to invoke()are immediately executed.
- 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, Costin Manolache
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected BaseNotificationBroadcasterNotification broadcaster for attribute changes.protected BaseNotificationBroadcasterNotification broadcaster for general notifications.protected ManagedBeanMetadata for the mbean instance.protected ObjectNameprotected ObjectThe managed resource this MBean is associated with (if any).protected String
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) Add an attribute change notification event listener to this MBean.voidaddNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) Add a notification event listener to this MBean.getAttribute(String name) Obtain and return the value of a specific attribute of this MBean.getAttributes(String[] names) Obtain and return the values of several attributes of this MBean.Get the instance handle of the object against which we execute all methods in this ModelMBean management interface.Return theMBeanInfoobject for this MBean.Return anMBeanNotificationInfoobject describing the notifications sent by this MBean.Invoke a particular method on this MBean, and return any returned value.voidvoidpostRegister(Boolean registrationDone) voidpreRegister(MBeanServer server, ObjectName name) voidremoveAttributeChangeNotificationListener(NotificationListener listener, String name) Remove an attribute change notification event listener from this MBean.voidRemove a notification event listener from this MBean.voidsendAttributeChangeNotification(AttributeChangeNotification notification) Send anAttributeChangeNotificationto all registered listeners.voidsendAttributeChangeNotification(Attribute oldValue, Attribute newValue) Send anAttributeChangeNotificationto all registered listeners.voidsendNotification(String message) Send aNotificationwhich contains the specified string as ajmx.modelmbean.genericnotification.voidsendNotification(Notification notification) Send aNotificationto all registered listeners as ajmx.modelmbean.generalnotification.voidsetAttribute(Attribute attribute) Set the value of a specific attribute of this MBean.setAttributes(AttributeList attributes) Set the values of several attributes of this MBean.voidsetManagedBean(ManagedBean managedBean) voidsetManagedResource(Object resource, String type) Set the instance handle of the object against which we will execute all methods in this ModelMBean management interface.toString()
- 
Field Details- 
oname
- 
attributeBroadcasterNotification broadcaster for attribute changes.
- 
generalBroadcasterNotification broadcaster for general notifications.
- 
managedBeanMetadata for the mbean instance.
- 
resourceThe managed resource this MBean is associated with (if any).
- 
resourceType
 
- 
- 
Constructor Details- 
BaseModelMBeanpublic BaseModelMBean()
 
- 
- 
Method Details- 
getAttributepublic Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException Obtain and return the value of a specific attribute of this MBean.- Specified by:
- getAttributein interface- DynamicMBean
- Parameters:
- name- Name of the requested attribute
- Throws:
- 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 getter
 
- 
getAttributesObtain and return the values of several attributes of this MBean.- Specified by:
- getAttributesin interface- DynamicMBean
- Parameters:
- names- Names of the requested attributes
 
- 
setManagedBean
- 
getMBeanInfoReturn theMBeanInfoobject for this MBean.- Specified by:
- getMBeanInfoin interface- DynamicMBean
 
- 
invokepublic Object invoke(String name, Object[] params, String[] signature) throws MBeanException, ReflectionException 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. - Specified by:
- invokein interface- DynamicMBean
- Parameters:
- name- Name of the operation to be invoked
- params- Array containing the method parameters of this operation
- signature- Array containing the class names representing the signature of this operation
- Throws:
- MBeanException- if the initializer of an object throws an exception
- ReflectionException- if a Java reflection exception occurs when invoking a method
 
- 
setAttributepublic void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException Set the value of a specific attribute of this MBean.- Specified by:
- setAttributein interface- DynamicMBean
- Parameters:
- attribute- The identification of the attribute to be set and the new value
- Throws:
- 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 getter
 
- 
toString
- 
setAttributesSet the values of several attributes of this MBean.- Specified by:
- setAttributesin interface- DynamicMBean
- Parameters:
- attributes- THe names and values to be set
- Returns:
- The list of attributes that were set and their new values
 
- 
getManagedResourcepublic Object getManagedResource() throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsExceptionGet the instance handle of the object against which we execute all methods in this ModelMBean management interface.- Returns:
- the backend managed object
- Throws:
- InstanceNotFoundException- if the managed resource object cannot be found
- InvalidTargetObjectTypeException- if the managed resource object is of the wrong type
- MBeanException- if the initializer of the object throws an exception
- RuntimeOperationsException- if the managed resource or the resource type is- nullor invalid
 
- 
setManagedResourcepublic void setManagedResource(Object resource, String type) throws InstanceNotFoundException, MBeanException, RuntimeOperationsException Set the instance handle of the object against which we will execute all methods in this ModelMBean management interface. The caller can provide the mbean instance or the object name to the resource, if needed.- Parameters:
- resource- The resource object to be managed
- type- The type of reference for the managed resource ("ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference")
- Throws:
- 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- nullor invalid
 
- 
addAttributeChangeNotificationListenerpublic void addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) throws IllegalArgumentException Add an attribute change notification event listener to this MBean.- Specified by:
- addAttributeChangeNotificationListenerin interface- ModelMBeanNotificationBroadcaster
- Parameters:
- listener- Listener that will receive event notifications
- name- Name of the attribute of interest, or- nullto indicate interest in all attributes
- handback- Handback object to be sent along with event notifications
- Throws:
- IllegalArgumentException- if the listener parameter is null
 
- 
removeAttributeChangeNotificationListenerpublic void removeAttributeChangeNotificationListener(NotificationListener listener, String name) throws ListenerNotFoundException Remove an attribute change notification event listener from this MBean.- Specified by:
- removeAttributeChangeNotificationListenerin interface- ModelMBeanNotificationBroadcaster
- Parameters:
- listener- The listener to be removed
- name- The attribute name for which no more events are required
- Throws:
- ListenerNotFoundException- if this listener is not registered in the MBean
 
- 
sendAttributeChangeNotificationpublic void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException Send anAttributeChangeNotificationto all registered listeners.- Specified by:
- sendAttributeChangeNotificationin interface- ModelMBeanNotificationBroadcaster
- Parameters:
- notification- The- AttributeChangeNotificationthat will be passed
- Throws:
- MBeanException- if an object initializer throws an exception
- RuntimeOperationsException- wraps IllegalArgumentException when the specified notification is- nullor invalid
 
- 
sendAttributeChangeNotificationpublic void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException Send anAttributeChangeNotificationto all registered listeners.- Specified by:
- sendAttributeChangeNotificationin interface- ModelMBeanNotificationBroadcaster
- Parameters:
- oldValue- The original value of the- Attribute
- newValue- The new value of the- Attribute
- Throws:
- MBeanException- if an object initializer throws an exception
- RuntimeOperationsException- wraps IllegalArgumentException when the specified notification is- nullor invalid
 
- 
sendNotificationpublic void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException Send aNotificationto all registered listeners as ajmx.modelmbean.generalnotification.- Specified by:
- sendNotificationin interface- ModelMBeanNotificationBroadcaster
- Parameters:
- notification- The- Notificationthat will be passed
- Throws:
- MBeanException- if an object initializer throws an exception
- RuntimeOperationsException- wraps IllegalArgumentException when the specified notification is- nullor invalid
 
- 
sendNotificationSend aNotificationwhich contains the specified string as ajmx.modelmbean.genericnotification.- Specified by:
- sendNotificationin interface- ModelMBeanNotificationBroadcaster
- Parameters:
- message- The message string to be passed
- Throws:
- MBeanException- if an object initializer throws an exception
- RuntimeOperationsException- wraps IllegalArgumentException when the specified notification is- nullor invalid
 
- 
addNotificationListenerpublic void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException Add a notification event listener to this MBean.- Specified by:
- addNotificationListenerin interface- NotificationBroadcaster
- Parameters:
- listener- Listener that will receive event notifications
- filter- Filter object used to filter event notifications actually delivered, or- nullfor no filtering
- handback- Handback object to be sent along with event notifications
- Throws:
- IllegalArgumentException- if the listener parameter is null
 
- 
getNotificationInfoReturn anMBeanNotificationInfoobject describing the notifications sent by this MBean.- Specified by:
- getNotificationInfoin interface- NotificationBroadcaster
 
- 
removeNotificationListenerpublic void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException Remove a notification event listener from this MBean.- Specified by:
- removeNotificationListenerin interface- NotificationBroadcaster
- Parameters:
- listener- The listener to be removed (any and all registrations for this listener will be eliminated)
- Throws:
- ListenerNotFoundException- if this listener is not registered in the MBean
 
- 
getModelerType
- 
getClassName
- 
getJmxName
- 
getObjectName
- 
preRegister- Specified by:
- preRegisterin interface- MBeanRegistration
- Throws:
- Exception
 
- 
postRegister- Specified by:
- postRegisterin interface- MBeanRegistration
 
- 
preDeregister- Specified by:
- preDeregisterin interface- MBeanRegistration
- Throws:
- Exception
 
- 
postDeregisterpublic void postDeregister()- Specified by:
- postDeregisterin interface- MBeanRegistration
 
 
-