BaseModelMBean (Apache Tomcat 9.0.117 API Documentation)
Description: declaration: package: org.apache.tomcat.util.modeler, class: BaseModelMBean

# 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 a mlet or anywhere an MBean would be used.

Limitations:

- Only managed resources of type `objectReference` are 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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected BaseNotificationBroadcaster`
  `attributeBroadcaster`
  Notification broadcaster for attribute changes.
  `protected BaseNotificationBroadcaster`
  `generalBroadcaster`
  Notification broadcaster for general notifications.
  `protected ManagedBean`
  `managedBean`
  Metadata for the mbean instance.
  `protected ObjectName`
  `oname`
  `protected Object`
  `resource`
  The managed resource this MBean is associated with (if any).
  `protected String`
  `resourceType`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BaseModelMBean()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback)`
  `void`
  `addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)`
  `Object`
  `getAttribute(String name)`
  `AttributeList`
  `getAttributes(String[] names)`
  `String`
  `getClassName()`
  `ObjectName`
  `getJmxName()`
  `Object`
  `getManagedResource()`
  Get the instance handle of the object against which we execute all methods in this ModelMBean management interface.
  `MBeanInfo`
  `getMBeanInfo()`
  Return the `MBeanInfo` object for this MBean.
  `String`
  `getModelerType()`
  `MBeanNotificationInfo[]`
  `getNotificationInfo()`
  `String`
  `getObjectName()`
  `Object`
  `invoke(String name, Object[] params, String[] signature)`
  `void`
  `postDeregister()`
  `void`
  `postRegister(Boolean registrationDone)`
  `void`
  `preDeregister()`
  `ObjectName`
  `preRegister(MBeanServer server, ObjectName name)`
  `void`
  `removeAttributeChangeNotificationListener(NotificationListener listener, String name)`
  `void`
  `removeNotificationListener(NotificationListener listener)`
  `void`
  `sendAttributeChangeNotification(AttributeChangeNotification notification)`
  `void`
  `sendAttributeChangeNotification(Attribute oldValue, Attribute newValue)`
  `void`
  `sendNotification(String message)`
  `void`
  `sendNotification(Notification notification)`
  `void`
  `setAttribute(Attribute attribute)`
  `AttributeList`
  `setAttributes(AttributeList attributes)`
  `void`
  `setManagedBean(ManagedBean managedBean)`
  `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.
  `String`
  `toString()`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### oname

    protected ObjectName oname

  - ### attributeBroadcaster

    protected BaseNotificationBroadcaster attributeBroadcaster
    Notification broadcaster for attribute changes.

  - ### generalBroadcaster

    protected BaseNotificationBroadcaster generalBroadcaster
    Notification broadcaster for general notifications.

  - ### managedBean

    protected ManagedBean managedBean
    Metadata for the mbean instance.

  - ### resource

    protected Object resource
    The managed resource this MBean is associated with (if any).

  - ### resourceType

    protected String resourceType

- ## Constructor Details

  - ### BaseModelMBean

    public BaseModelMBean()

- ## Method Details

  - ### getAttribute

    public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException
    Specified by:
      `getAttribute` in interface `DynamicMBean`
    Throws:
      `AttributeNotFoundException`
      `MBeanException`
      `ReflectionException`

  - ### getAttributes

    public AttributeList getAttributes(String[] names)
    Specified by:
      `getAttributes` in interface `DynamicMBean`

  - ### setManagedBean

    public void setManagedBean(ManagedBean managedBean)

  - ### getMBeanInfo

    public MBeanInfo getMBeanInfo()
    Return the `MBeanInfo` object for this MBean.
    Specified by:
      `getMBeanInfo` in interface `DynamicMBean`

  - ### 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:
      `invoke` in interface `DynamicMBean`
    Throws:
      `MBeanException`
      `ReflectionException`

  - ### setAttribute

    public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
    Specified by:
      `setAttribute` in interface `DynamicMBean`
    Throws:
      `AttributeNotFoundException`
      `MBeanException`
      `ReflectionException`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### setAttributes

    public AttributeList setAttributes(AttributeList attributes)
    Specified by:
      `setAttributes` in interface `DynamicMBean`

  - ### getManagedResource

    public Object getManagedResource() throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException
    Get 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 `null` or 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 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 `null` or invalid

  - ### addAttributeChangeNotificationListener

    public void addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) throws IllegalArgumentException
    Specified by:
      `addAttributeChangeNotificationListener` in interface `ModelMBeanNotificationBroadcaster`
    Throws:
      `IllegalArgumentException`

  - ### removeAttributeChangeNotificationListener

    public void removeAttributeChangeNotificationListener(NotificationListener listener, String name) throws ListenerNotFoundException
    Specified by:
      `removeAttributeChangeNotificationListener` in interface `ModelMBeanNotificationBroadcaster`
    Throws:
      `ListenerNotFoundException`

  - ### sendAttributeChangeNotification

    public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException
    Specified by:
      `sendAttributeChangeNotification` in interface `ModelMBeanNotificationBroadcaster`
    Throws:
      `MBeanException`
      `RuntimeOperationsException`

  - ### sendAttributeChangeNotification

    public void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException
    Specified by:
      `sendAttributeChangeNotification` in interface `ModelMBeanNotificationBroadcaster`
    Throws:
      `MBeanException`
      `RuntimeOperationsException`

  - ### sendNotification

    public void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException
    Specified by:
      `sendNotification` in interface `ModelMBeanNotificationBroadcaster`
    Throws:
      `MBeanException`
      `RuntimeOperationsException`

  - ### sendNotification

    public void sendNotification(String message) throws MBeanException, RuntimeOperationsException
    Specified by:
      `sendNotification` in interface `ModelMBeanNotificationBroadcaster`
    Throws:
      `MBeanException`
      `RuntimeOperationsException`

  - ### addNotificationListener

    public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException
    Specified by:
      `addNotificationListener` in interface `NotificationBroadcaster`
    Throws:
      `IllegalArgumentException`

  - ### getNotificationInfo

    public MBeanNotificationInfo[] getNotificationInfo()
    Specified by:
      `getNotificationInfo` in interface `NotificationBroadcaster`

  - ### removeNotificationListener

    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
    Specified by:
      `removeNotificationListener` in interface `NotificationBroadcaster`
    Throws:
      `ListenerNotFoundException`

  - ### getModelerType

    public String getModelerType()

  - ### getClassName

    public String getClassName()
    Returns:
      the fully qualified Java class name of the managed object for this MBean

  - ### getJmxName

    public ObjectName getJmxName()

  - ### getObjectName

    public String getObjectName()

  - ### preRegister

    public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
    Specified by:
      `preRegister` in interface `MBeanRegistration`
    Throws:
      `Exception`

  - ### postRegister

    public void postRegister(Boolean registrationDone)
    Specified by:
      `postRegister` in interface `MBeanRegistration`

  - ### preDeregister

    public void preDeregister() throws Exception
    Specified by:
      `preDeregister` in interface `MBeanRegistration`
    Throws:
      `Exception`

  - ### postDeregister

    public void postDeregister()
    Specified by:
      `postDeregister` in interface `MBeanRegistration`