org.springframework.jmx.export.assembler

Class AbstractMBeanInfoAssembler

  • java.lang.Object
    • org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
  • All Implemented Interfaces:
    MBeanInfoAssembler
    Direct Known Subclasses:
    AbstractReflectiveMBeanInfoAssembler


    public abstract class AbstractMBeanInfoAssembler
    extends java.lang.Object
    implements MBeanInfoAssembler
    Abstract implementation of the MBeanInfoAssembler interface that encapsulates the creation of a ModelMBeanInfo instance but delegates the creation of metadata to subclasses.

    This class offers two flavors of Class extraction from a managed bean instance: getTargetClass(java.lang.Object), extracting the target class behind any kind of AOP proxy, and getClassToExpose(java.lang.Object), returning the class or interface that will be searched for annotations and exposed to the JMX runtime.

    Since:
    1.2
    Author:
    Rob Harrop, Juergen Hoeller
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      protected void checkManagedBean(java.lang.Object managedBean)
      Check the given bean instance, throwing an IllegalArgumentException if it is not eligible for exposure with this assembler.
      protected abstract javax.management.modelmbean.ModelMBeanAttributeInfo[] getAttributeInfo(java.lang.Object managedBean, java.lang.String beanKey)
      Get the attribute metadata for the MBean resource.
      protected java.lang.String getClassName(java.lang.Object managedBean, java.lang.String beanKey)
      Get the class name of the MBean resource.
      protected java.lang.Class<?> getClassToExpose(java.lang.Class<?> beanClass)
      Return the class or interface to expose for the given bean class.
      protected java.lang.Class<?> getClassToExpose(java.lang.Object managedBean)
      Return the class or interface to expose for the given bean.
      protected javax.management.modelmbean.ModelMBeanConstructorInfo[] getConstructorInfo(java.lang.Object managedBean, java.lang.String beanKey)
      Get the constructor metadata for the MBean resource.
      protected java.lang.String getDescription(java.lang.Object managedBean, java.lang.String beanKey)
      Get the description of the MBean resource.
      javax.management.modelmbean.ModelMBeanInfo getMBeanInfo(java.lang.Object managedBean, java.lang.String beanKey)
      Create an instance of the ModelMBeanInfoSupport class supplied with all JMX implementations and populates the metadata through calls to the subclass.
      protected javax.management.modelmbean.ModelMBeanNotificationInfo[] getNotificationInfo(java.lang.Object managedBean, java.lang.String beanKey)
      Get the notification metadata for the MBean resource.
      protected abstract javax.management.modelmbean.ModelMBeanOperationInfo[] getOperationInfo(java.lang.Object managedBean, java.lang.String beanKey)
      Get the operation metadata for the MBean resource.
      protected java.lang.Class<?> getTargetClass(java.lang.Object managedBean)
      Return the actual bean class of the given bean instance.
      protected void populateMBeanDescriptor(javax.management.Descriptor descriptor, java.lang.Object managedBean, java.lang.String beanKey)
      Called after the ModelMBeanInfo instance has been constructed but before it is passed to the MBeanExporter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractMBeanInfoAssembler

        public AbstractMBeanInfoAssembler()
    • Method Detail

      • checkManagedBean

        protected void checkManagedBean(java.lang.Object managedBean)
                                 throws java.lang.IllegalArgumentException
        Check the given bean instance, throwing an IllegalArgumentException if it is not eligible for exposure with this assembler.

        Default implementation is empty, accepting every bean instance.

        Parameters:
        managedBean - the bean that will be exposed (might be an AOP proxy)
        Throws:
        java.lang.IllegalArgumentException - the bean is not valid for exposure
      • getTargetClass

        protected java.lang.Class<?> getTargetClass(java.lang.Object managedBean)
        Return the actual bean class of the given bean instance. This is the class exposed to description-style JMX properties.

        Default implementation returns the target class for an AOP proxy, and the plain bean class else.

        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        Returns:
        the bean class to expose
        See Also:
        AopUtils.getTargetClass(Object)
      • getClassToExpose

        protected java.lang.Class<?> getClassToExpose(java.lang.Object managedBean)
        Return the class or interface to expose for the given bean. This is the class that will be searched for attributes and operations (for example, checked for annotations).
        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        Returns:
        the bean class to expose
        See Also:
        JmxUtils.getClassToExpose(Object)
      • getClassToExpose

        protected java.lang.Class<?> getClassToExpose(java.lang.Class<?> beanClass)
        Return the class or interface to expose for the given bean class. This is the class that will be searched for attributes and operations
        Parameters:
        beanClass - the bean class (might be an AOP proxy class)
        Returns:
        the bean class to expose
        See Also:
        JmxUtils.getClassToExpose(Class)
      • getClassName

        protected java.lang.String getClassName(java.lang.Object managedBean,
                                                java.lang.String beanKey)
                                         throws javax.management.JMException
        Get the class name of the MBean resource.

        Default implementation returns a simple description for the MBean based on the class name.

        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        beanKey - the key associated with the MBean in the beans map of the MBeanExporter
        Returns:
        the MBean description
        Throws:
        javax.management.JMException - in case of errors
      • getDescription

        protected java.lang.String getDescription(java.lang.Object managedBean,
                                                  java.lang.String beanKey)
                                           throws javax.management.JMException
        Get the description of the MBean resource.

        Default implementation returns a simple description for the MBean based on the class name.

        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        beanKey - the key associated with the MBean in the beans map of the MBeanExporter
        Throws:
        javax.management.JMException - in case of errors
      • populateMBeanDescriptor

        protected void populateMBeanDescriptor(javax.management.Descriptor descriptor,
                                               java.lang.Object managedBean,
                                               java.lang.String beanKey)
                                        throws javax.management.JMException
        Called after the ModelMBeanInfo instance has been constructed but before it is passed to the MBeanExporter.

        Subclasses can implement this method to add additional descriptors to the MBean metadata. Default implementation is empty.

        Parameters:
        descriptor - the Descriptor for the MBean resource.
        managedBean - the bean instance (might be an AOP proxy)
        beanKey - the key associated with the MBean in the beans map of the MBeanExporter
        Throws:
        javax.management.JMException - in case of errors
      • getConstructorInfo

        protected javax.management.modelmbean.ModelMBeanConstructorInfo[] getConstructorInfo(java.lang.Object managedBean,
                                                                                             java.lang.String beanKey)
                                                                                      throws javax.management.JMException
        Get the constructor metadata for the MBean resource. Subclasses should implement this method to return the appropriate metadata for all constructors that should be exposed in the management interface for the managed resource.

        Default implementation returns an empty array of ModelMBeanConstructorInfo.

        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        beanKey - the key associated with the MBean in the beans map of the MBeanExporter
        Returns:
        the constructor metadata
        Throws:
        javax.management.JMException - in case of errors
      • getNotificationInfo

        protected javax.management.modelmbean.ModelMBeanNotificationInfo[] getNotificationInfo(java.lang.Object managedBean,
                                                                                               java.lang.String beanKey)
                                                                                        throws javax.management.JMException
        Get the notification metadata for the MBean resource. Subclasses should implement this method to return the appropriate metadata for all notifications that should be exposed in the management interface for the managed resource.

        Default implementation returns an empty array of ModelMBeanNotificationInfo.

        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        beanKey - the key associated with the MBean in the beans map of the MBeanExporter
        Returns:
        the notification metadata
        Throws:
        javax.management.JMException - in case of errors
      • getAttributeInfo

        protected abstract javax.management.modelmbean.ModelMBeanAttributeInfo[] getAttributeInfo(java.lang.Object managedBean,
                                                                                                  java.lang.String beanKey)
                                                                                           throws javax.management.JMException
        Get the attribute metadata for the MBean resource. Subclasses should implement this method to return the appropriate metadata for all the attributes that should be exposed in the management interface for the managed resource.
        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        beanKey - the key associated with the MBean in the beans map of the MBeanExporter
        Returns:
        the attribute metadata
        Throws:
        javax.management.JMException - in case of errors
      • getOperationInfo

        protected abstract javax.management.modelmbean.ModelMBeanOperationInfo[] getOperationInfo(java.lang.Object managedBean,
                                                                                                  java.lang.String beanKey)
                                                                                           throws javax.management.JMException
        Get the operation metadata for the MBean resource. Subclasses should implement this method to return the appropriate metadata for all operations that should be exposed in the management interface for the managed resource.
        Parameters:
        managedBean - the bean instance (might be an AOP proxy)
        beanKey - the key associated with the MBean in the beans map of the MBeanExporter
        Returns:
        the operation metadata
        Throws:
        javax.management.JMException - in case of errors