Class InterfaceBasedMBeanInfoAssembler

All Implemented Interfaces:
Aware, BeanClassLoaderAware, InitializingBean, MBeanInfoAssembler

public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanInfoAssembler implements BeanClassLoaderAware, InitializingBean
Subclass of AbstractReflectiveMBeanInfoAssembler that allows for the management interface of a bean to be defined using arbitrary interfaces. Any methods or properties that are defined in those interfaces are exposed as MBean operations and attributes.

By default, this class votes on the inclusion of each operation or attribute based on the interfaces implemented by the bean class. However, you can supply an array of interfaces via the managedInterfaces property that will be used instead. If you have multiple beans and you wish each bean to use a different set of interfaces, then you can map bean keys (that is the name used to pass the bean to the MBeanExporter) to a list of interface names using the interfaceMappings property.

If you specify values for both interfaceMappings and managedInterfaces, Spring will attempt to find interfaces in the mappings first. If no interfaces for the bean are found, it will use the interfaces defined by managedInterfaces.

Since:
1.2
Author:
Rob Harrop, Juergen Hoeller
See Also:
  • Constructor Details

    • InterfaceBasedMBeanInfoAssembler

      public InterfaceBasedMBeanInfoAssembler()
  • Method Details

    • setManagedInterfaces

      public void setManagedInterfaces(@Nullable Class<?>... managedInterfaces)
      Set the array of interfaces to use for creating the management info. These interfaces will be used for a bean if no entry corresponding to that bean is found in the interfaceMappings property.
      Parameters:
      managedInterfaces - an array of classes indicating the interfaces to use. Each entry MUST be an interface.
      See Also:
    • setInterfaceMappings

      public void setInterfaceMappings(@Nullable Properties mappings)
      Set the mappings of bean keys to a comma-separated list of interface names.

      The property key should match the bean key and the property value should match the list of interface names. When searching for interfaces for a bean, Spring will check these mappings first.

      Parameters:
      mappings - the mappings of bean keys to interface names
    • setBeanClassLoader

      public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader)
      Description copied from interface: BeanClassLoaderAware
      Callback that supplies the bean class loader to a bean instance.

      Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean.afterPropertiesSet() method or a custom init-method.

      Specified by:
      setBeanClassLoader in interface BeanClassLoaderAware
      Parameters:
      beanClassLoader - the owning class loader
    • afterPropertiesSet

      public void afterPropertiesSet()
      Description copied from interface: InitializingBean
      Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

      This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

      Specified by:
      afterPropertiesSet in interface InitializingBean
    • includeReadAttribute

      protected boolean includeReadAttribute(Method method, String beanKey)
      Check to see if the Method is declared in one of the configured interfaces and that it is public.
      Specified by:
      includeReadAttribute in class AbstractReflectiveMBeanInfoAssembler
      Parameters:
      method - the accessor Method.
      beanKey - the key associated with the MBean in the beans Map.
      Returns:
      true if the Method is declared in one of the configured interfaces, otherwise false.
    • includeWriteAttribute

      protected boolean includeWriteAttribute(Method method, String beanKey)
      Check to see if the Method is declared in one of the configured interfaces and that it is public.
      Specified by:
      includeWriteAttribute in class AbstractReflectiveMBeanInfoAssembler
      Parameters:
      method - the mutator Method.
      beanKey - the key associated with the MBean in the beans Map.
      Returns:
      true if the Method is declared in one of the configured interfaces, otherwise false.
    • includeOperation

      protected boolean includeOperation(Method method, String beanKey)
      Check to see if the Method is declared in one of the configured interfaces and that it is public.
      Specified by:
      includeOperation in class AbstractReflectiveMBeanInfoAssembler
      Parameters:
      method - the operation Method.
      beanKey - the key associated with the MBean in the beans Map.
      Returns:
      true if the Method is declared in one of the configured interfaces, otherwise false.