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) voidaddNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) getAttribute(String name) getAttributes(String[] names) Get the instance handle of the object against which we execute all methods in this ModelMBean management interface.Return theMBeanInfoobject for this MBean.voidvoidpostRegister(Boolean registrationDone) voidpreRegister(MBeanServer server, ObjectName name) voidremoveAttributeChangeNotificationListener(NotificationListener listener, String name) voidvoidsendAttributeChangeNotification(AttributeChangeNotification notification) voidsendAttributeChangeNotification(Attribute oldValue, Attribute newValue) voidsendNotification(String message) voidsendNotification(Notification notification) voidsetAttribute(Attribute attribute) setAttributes(AttributeList attributes) 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 - Specified by:
- getAttributein interface- DynamicMBean
- Throws:
- AttributeNotFoundException
- MBeanException
- ReflectionException
 
- 
getAttributes- Specified by:
- getAttributesin interface- DynamicMBean
 
- 
setManagedBean
- 
getMBeanInfoReturn theMBeanInfoobject for this MBean.- Specified by:
- getMBeanInfoin interface- DynamicMBean
 
- 
invokepublic Object invoke(String name, Object[] params, 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. - Specified by:
- invokein interface- DynamicMBean
- Throws:
- MBeanException
- ReflectionException
 
- 
setAttributepublic void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException - Specified by:
- setAttributein interface- DynamicMBean
- Throws:
- AttributeNotFoundException
- MBeanException
- ReflectionException
 
- 
toString
- 
setAttributes- Specified by:
- setAttributesin interface- DynamicMBean
 
- 
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 - Specified by:
- addAttributeChangeNotificationListenerin interface- ModelMBeanNotificationBroadcaster
- Throws:
- IllegalArgumentException
 
- 
removeAttributeChangeNotificationListenerpublic void removeAttributeChangeNotificationListener(NotificationListener listener, String name) throws ListenerNotFoundException - Specified by:
- removeAttributeChangeNotificationListenerin interface- ModelMBeanNotificationBroadcaster
- Throws:
- ListenerNotFoundException
 
- 
sendAttributeChangeNotificationpublic void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException - Specified by:
- sendAttributeChangeNotificationin interface- ModelMBeanNotificationBroadcaster
- Throws:
- MBeanException
- RuntimeOperationsException
 
- 
sendAttributeChangeNotificationpublic void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException - Specified by:
- sendAttributeChangeNotificationin interface- ModelMBeanNotificationBroadcaster
- Throws:
- MBeanException
- RuntimeOperationsException
 
- 
sendNotificationpublic void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException - Specified by:
- sendNotificationin interface- ModelMBeanNotificationBroadcaster
- Throws:
- MBeanException
- RuntimeOperationsException
 
- 
sendNotification- Specified by:
- sendNotificationin interface- ModelMBeanNotificationBroadcaster
- Throws:
- MBeanException
- RuntimeOperationsException
 
- 
addNotificationListenerpublic void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException - Specified by:
- addNotificationListenerin interface- NotificationBroadcaster
- Throws:
- IllegalArgumentException
 
- 
getNotificationInfo- Specified by:
- getNotificationInfoin interface- NotificationBroadcaster
 
- 
removeNotificationListenerpublic void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException - Specified by:
- removeNotificationListenerin interface- NotificationBroadcaster
- Throws:
- ListenerNotFoundException
 
- 
getModelerType
- 
getClassName- Returns:
- the fully qualified Java class name of the managed object for this MBean
 
- 
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
 
 
-