Class BaseModelMBean

  • All Implemented Interfaces:
    javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.modelmbean.ModelMBeanNotificationBroadcaster, javax.management.NotificationBroadcaster
    Direct Known Subclasses:
    BaseCatalinaMBean, DataSourceUserDatabaseMBean, GroupMBean, NamingResourcesMBean, RequestGroupInfo, RoleMBean, SparseUserDatabaseMBean, UpgradeGroupInfo, UserMBean

    public class BaseModelMBean
    extends java.lang.Object
    implements javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.modelmbean.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 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
    Author:
    Craig R. McClanahan, Costin Manolache
    • Field Detail

      • oname

        protected javax.management.ObjectName oname
      • managedBean

        protected ManagedBean managedBean
        Metadata for the mbean instance.
      • resource

        protected java.lang.Object resource
        The managed resource this MBean is associated with (if any).
      • resourceType

        protected java.lang.String resourceType
    • Constructor Detail

      • BaseModelMBean

        public BaseModelMBean()
    • Method Detail

      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
                                      throws javax.management.AttributeNotFoundException,
                                             javax.management.MBeanException,
                                             javax.management.ReflectionException
        Specified by:
        getAttribute in interface javax.management.DynamicMBean
        Throws:
        javax.management.AttributeNotFoundException
        javax.management.MBeanException
        javax.management.ReflectionException
      • getAttributes

        public javax.management.AttributeList getAttributes​(java.lang.String[] names)
        Specified by:
        getAttributes in interface javax.management.DynamicMBean
      • setManagedBean

        public void setManagedBean​(ManagedBean managedBean)
      • getMBeanInfo

        public javax.management.MBeanInfo getMBeanInfo()
        Return the MBeanInfo object for this MBean.
        Specified by:
        getMBeanInfo in interface javax.management.DynamicMBean
      • invoke

        public java.lang.Object invoke​(java.lang.String name,
                                       java.lang.Object[] params,
                                       java.lang.String[] signature)
                                throws javax.management.MBeanException,
                                       javax.management.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 javax.management.DynamicMBean
        Throws:
        javax.management.MBeanException
        javax.management.ReflectionException
      • setAttribute

        public void setAttribute​(javax.management.Attribute attribute)
                          throws javax.management.AttributeNotFoundException,
                                 javax.management.MBeanException,
                                 javax.management.ReflectionException
        Specified by:
        setAttribute in interface javax.management.DynamicMBean
        Throws:
        javax.management.AttributeNotFoundException
        javax.management.MBeanException
        javax.management.ReflectionException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setAttributes

        public javax.management.AttributeList setAttributes​(javax.management.AttributeList attributes)
        Specified by:
        setAttributes in interface javax.management.DynamicMBean
      • getManagedResource

        public java.lang.Object getManagedResource()
                                            throws javax.management.InstanceNotFoundException,
                                                   javax.management.modelmbean.InvalidTargetObjectTypeException,
                                                   javax.management.MBeanException,
                                                   javax.management.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:
        javax.management.InstanceNotFoundException - if the managed resource object cannot be found
        javax.management.modelmbean.InvalidTargetObjectTypeException - if the managed resource object is of the wrong type
        javax.management.MBeanException - if the initializer of the object throws an exception
        javax.management.RuntimeOperationsException - if the managed resource or the resource type is null or invalid
      • setManagedResource

        public void setManagedResource​(java.lang.Object resource,
                                       java.lang.String type)
                                throws javax.management.InstanceNotFoundException,
                                       javax.management.MBeanException,
                                       javax.management.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:
        javax.management.InstanceNotFoundException - if the managed resource object cannot be found
        javax.management.MBeanException - if the initializer of the object throws an exception
        javax.management.RuntimeOperationsException - if the managed resource or the resource type is null or invalid
      • addAttributeChangeNotificationListener

        public void addAttributeChangeNotificationListener​(javax.management.NotificationListener listener,
                                                           java.lang.String name,
                                                           java.lang.Object handback)
                                                    throws java.lang.IllegalArgumentException
        Specified by:
        addAttributeChangeNotificationListener in interface javax.management.modelmbean.ModelMBeanNotificationBroadcaster
        Throws:
        java.lang.IllegalArgumentException
      • removeAttributeChangeNotificationListener

        public void removeAttributeChangeNotificationListener​(javax.management.NotificationListener listener,
                                                              java.lang.String name)
                                                       throws javax.management.ListenerNotFoundException
        Specified by:
        removeAttributeChangeNotificationListener in interface javax.management.modelmbean.ModelMBeanNotificationBroadcaster
        Throws:
        javax.management.ListenerNotFoundException
      • sendAttributeChangeNotification

        public void sendAttributeChangeNotification​(javax.management.AttributeChangeNotification notification)
                                             throws javax.management.MBeanException,
                                                    javax.management.RuntimeOperationsException
        Specified by:
        sendAttributeChangeNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcaster
        Throws:
        javax.management.MBeanException
        javax.management.RuntimeOperationsException
      • sendAttributeChangeNotification

        public void sendAttributeChangeNotification​(javax.management.Attribute oldValue,
                                                    javax.management.Attribute newValue)
                                             throws javax.management.MBeanException,
                                                    javax.management.RuntimeOperationsException
        Specified by:
        sendAttributeChangeNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcaster
        Throws:
        javax.management.MBeanException
        javax.management.RuntimeOperationsException
      • sendNotification

        public void sendNotification​(javax.management.Notification notification)
                              throws javax.management.MBeanException,
                                     javax.management.RuntimeOperationsException
        Specified by:
        sendNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcaster
        Throws:
        javax.management.MBeanException
        javax.management.RuntimeOperationsException
      • sendNotification

        public void sendNotification​(java.lang.String message)
                              throws javax.management.MBeanException,
                                     javax.management.RuntimeOperationsException
        Specified by:
        sendNotification in interface javax.management.modelmbean.ModelMBeanNotificationBroadcaster
        Throws:
        javax.management.MBeanException
        javax.management.RuntimeOperationsException
      • addNotificationListener

        public void addNotificationListener​(javax.management.NotificationListener listener,
                                            javax.management.NotificationFilter filter,
                                            java.lang.Object handback)
                                     throws java.lang.IllegalArgumentException
        Specified by:
        addNotificationListener in interface javax.management.NotificationBroadcaster
        Throws:
        java.lang.IllegalArgumentException
      • getNotificationInfo

        public javax.management.MBeanNotificationInfo[] getNotificationInfo()
        Specified by:
        getNotificationInfo in interface javax.management.NotificationBroadcaster
      • removeNotificationListener

        public void removeNotificationListener​(javax.management.NotificationListener listener)
                                        throws javax.management.ListenerNotFoundException
        Specified by:
        removeNotificationListener in interface javax.management.NotificationBroadcaster
        Throws:
        javax.management.ListenerNotFoundException
      • getModelerType

        public java.lang.String getModelerType()
      • getClassName

        public java.lang.String getClassName()
        Returns:
        the fully qualified Java class name of the managed object for this MBean
      • getJmxName

        public javax.management.ObjectName getJmxName()
      • getObjectName

        public java.lang.String getObjectName()
      • preRegister

        public javax.management.ObjectName preRegister​(javax.management.MBeanServer server,
                                                       javax.management.ObjectName name)
                                                throws java.lang.Exception
        Specified by:
        preRegister in interface javax.management.MBeanRegistration
        Throws:
        java.lang.Exception
      • postRegister

        public void postRegister​(java.lang.Boolean registrationDone)
        Specified by:
        postRegister in interface javax.management.MBeanRegistration
      • preDeregister

        public void preDeregister()
                           throws java.lang.Exception
        Specified by:
        preDeregister in interface javax.management.MBeanRegistration
        Throws:
        java.lang.Exception
      • postDeregister

        public void postDeregister()
        Specified by:
        postDeregister in interface javax.management.MBeanRegistration