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 Summary
FieldsModifier 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 Summary
Constructors -
Method Summary
Modifier 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
-
attributeBroadcaster
Notification broadcaster for attribute changes. -
generalBroadcaster
Notification broadcaster for general notifications. -
managedBean
Metadata for the mbean instance. -
resource
The managed resource this MBean is associated with (if any). -
resourceType
-
-
Constructor Details
-
BaseModelMBean
public BaseModelMBean()
-
-
Method Details
-
getAttribute
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException - Specified by:
getAttributein interfaceDynamicMBean- Throws:
AttributeNotFoundExceptionMBeanExceptionReflectionException
-
getAttributes
- Specified by:
getAttributesin interfaceDynamicMBean
-
setManagedBean
-
getMBeanInfo
Return theMBeanInfoobject for this MBean.- Specified by:
getMBeanInfoin interfaceDynamicMBean
-
invoke
public 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 interfaceDynamicMBean- Throws:
MBeanExceptionReflectionException
-
setAttribute
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException - Specified by:
setAttributein interfaceDynamicMBean- Throws:
AttributeNotFoundExceptionMBeanExceptionReflectionException
-
toString
-
setAttributes
- Specified by:
setAttributesin interfaceDynamicMBean
-
getManagedResource
public 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 foundInvalidTargetObjectTypeException- if the managed resource object is of the wrong typeMBeanException- if the initializer of the object throws an exceptionRuntimeOperationsException- if the managed resource or the resource type isnullor invalid
-
setManagedResource
public 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 managedtype- The type of reference for the managed resource ("ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference")- Throws:
InstanceNotFoundException- if the managed resource object cannot be foundMBeanException- if the initializer of the object throws an exceptionRuntimeOperationsException- if the managed resource or the resource type isnullor invalid
-
addAttributeChangeNotificationListener
public void addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) throws IllegalArgumentException - Specified by:
addAttributeChangeNotificationListenerin interfaceModelMBeanNotificationBroadcaster- Throws:
IllegalArgumentException
-
removeAttributeChangeNotificationListener
public void removeAttributeChangeNotificationListener(NotificationListener listener, String name) throws ListenerNotFoundException - Specified by:
removeAttributeChangeNotificationListenerin interfaceModelMBeanNotificationBroadcaster- Throws:
ListenerNotFoundException
-
sendAttributeChangeNotification
public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException - Specified by:
sendAttributeChangeNotificationin interfaceModelMBeanNotificationBroadcaster- Throws:
MBeanExceptionRuntimeOperationsException
-
sendAttributeChangeNotification
public void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException - Specified by:
sendAttributeChangeNotificationin interfaceModelMBeanNotificationBroadcaster- Throws:
MBeanExceptionRuntimeOperationsException
-
sendNotification
public void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException - Specified by:
sendNotificationin interfaceModelMBeanNotificationBroadcaster- Throws:
MBeanExceptionRuntimeOperationsException
-
sendNotification
- Specified by:
sendNotificationin interfaceModelMBeanNotificationBroadcaster- Throws:
MBeanExceptionRuntimeOperationsException
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException - Specified by:
addNotificationListenerin interfaceNotificationBroadcaster- Throws:
IllegalArgumentException
-
getNotificationInfo
- Specified by:
getNotificationInfoin interfaceNotificationBroadcaster
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException - Specified by:
removeNotificationListenerin interfaceNotificationBroadcaster- Throws:
ListenerNotFoundException
-
getModelerType
-
getClassName
- Returns:
- the fully qualified Java class name of the managed object for this MBean
-
getJmxName
-
getObjectName
-
preRegister
- Specified by:
preRegisterin interfaceMBeanRegistration- Throws:
Exception
-
postRegister
- Specified by:
postRegisterin interfaceMBeanRegistration
-
preDeregister
- Specified by:
preDeregisterin interfaceMBeanRegistration- Throws:
Exception
-
postDeregister
public void postDeregister()- Specified by:
postDeregisterin interfaceMBeanRegistration
-