public class

MetadataMBeanInfoAssembler

extends AbstractReflectiveMBeanInfoAssembler
implements InitializingBean AutodetectCapableMBeanInfoAssembler
java.lang.Object
   ↳ org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
     ↳ org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
       ↳ org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler

Class Overview

Implementation of the MBeanInfoAssembler interface that reads the management interface information from source level metadata.

Uses the JmxAttributeSource strategy interface, so that metadata can be read using any supported implementation. Out of the box, Spring provides an implementation based on JDK 1.5+ annotations, AnnotationJmxAttributeSource.

Summary

[Expand]
Inherited Constants
From class org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
Public Constructors
MetadataMBeanInfoAssembler()
Create a new MetadataMBeanInfoAssembler which needs to be configured through the setAttributeSource(JmxAttributeSource) method.
MetadataMBeanInfoAssembler(JmxAttributeSource attributeSource)
Create a new MetadataMBeanInfoAssembler for the given JmxAttributeSource.
Public Methods
void afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
boolean includeBean(Class<?> beanClass, String beanName)
Used for autodetection of beans.
void setAttributeSource(JmxAttributeSource attributeSource)
Set the JmxAttributeSource implementation to use for reading the metadata from the bean class.
Protected Methods
void checkManagedBean(Object managedBean)
Throws an IllegalArgumentException if it encounters a JDK dynamic proxy.
String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey)
Creates a description for the attribute corresponding to this property descriptor.
String getDescription(Object managedBean, String beanKey)
Reads managed resource description from the source level metadata.
ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey)
Reads the ManagedNotification metadata from the Class of the managed resource and generates and returns the corresponding ModelMBeanNotificationInfo metadata.
String getOperationDescription(Method method, String beanKey)
Retrieves the description for the supplied Method from the metadata.
MBeanParameterInfo[] getOperationParameters(Method method, String beanKey)
Reads MBeanParameterInfo from the ManagedOperationParameter attributes attached to a method.
boolean includeOperation(Method method, String beanKey)
Votes on the inclusion of an operation.
boolean includeReadAttribute(Method method, String beanKey)
Vote on the inclusion of an attribute accessor.
boolean includeWriteAttribute(Method method, String beanKey)
Votes on the inclusion of an attribute mutator.
void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey)
Adds descriptor fields from the ManagedAttribute attribute or the ManagedMetric attribute to the attribute descriptor.
void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey)
Adds descriptor fields from the ManagedResource attribute to the MBean descriptor.
void populateOperationDescriptor(Descriptor desc, Method method, String beanKey)
Adds descriptor fields from the ManagedAttribute attribute to the attribute descriptor.
[Expand]
Inherited Methods
From class org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
From class org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.jmx.export.assembler.AutodetectCapableMBeanInfoAssembler
From interface org.springframework.jmx.export.assembler.MBeanInfoAssembler

Public Constructors

public MetadataMBeanInfoAssembler ()

Create a new MetadataMBeanInfoAssembler which needs to be configured through the setAttributeSource(JmxAttributeSource) method.

public MetadataMBeanInfoAssembler (JmxAttributeSource attributeSource)

Create a new MetadataMBeanInfoAssembler for the given JmxAttributeSource.

Parameters
attributeSource the JmxAttributeSource to use

Public Methods

public void afterPropertiesSet ()

Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

public boolean includeBean (Class<?> beanClass, String beanName)

Used for autodetection of beans. Checks to see if the bean's class has a ManagedResource attribute. If so it will add it list of included beans.

Parameters
beanClass the class of the bean
beanName the name of the bean in the bean factory

public void setAttributeSource (JmxAttributeSource attributeSource)

Set the JmxAttributeSource implementation to use for reading the metadata from the bean class.

Protected Methods

protected void checkManagedBean (Object managedBean)

Throws an IllegalArgumentException if it encounters a JDK dynamic proxy. Metadata can only be read from target classes and CGLIB proxies!

Parameters
managedBean the bean that will be exposed (might be an AOP proxy)

protected String getAttributeDescription (PropertyDescriptor propertyDescriptor, String beanKey)

Creates a description for the attribute corresponding to this property descriptor. Attempts to create the description using metadata from either the getter or setter attributes, otherwise uses the property name.

Parameters
propertyDescriptor the PropertyDescriptor for the attribute
beanKey the key associated with the MBean in the beans map of the MBeanExporter
Returns
  • the description for the attribute

protected String getDescription (Object managedBean, String beanKey)

Reads managed resource description from the source level metadata. Returns an empty String if no description can be found.

Parameters
managedBean the bean instance (might be an AOP proxy)
beanKey the key associated with the MBean in the beans map of the MBeanExporter

protected ModelMBeanNotificationInfo[] getNotificationInfo (Object managedBean, String beanKey)

Reads the ManagedNotification metadata from the Class of the managed resource and generates and returns the corresponding ModelMBeanNotificationInfo metadata.

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

protected String getOperationDescription (Method method, String beanKey)

Retrieves the description for the supplied Method from the metadata. Uses the method name is no description is present in the metadata.

Parameters
method the operation method
beanKey the key associated with the MBean in the beans map of the MBeanExporter
Returns
  • the description for the operation

protected MBeanParameterInfo[] getOperationParameters (Method method, String beanKey)

Reads MBeanParameterInfo from the ManagedOperationParameter attributes attached to a method. Returns an empty array of MBeanParameterInfo if no attributes are found.

Parameters
method the Method to get the parameter information for
beanKey the key associated with the MBean in the beans map of the MBeanExporter
Returns
  • the MBeanParameterInfo array

protected boolean includeOperation (Method method, String beanKey)

Votes on the inclusion of an operation.

Parameters
method the operation method
beanKey the key associated with the MBean in the beans map
Returns
  • whether the method has the appropriate metadata

protected boolean includeReadAttribute (Method method, String beanKey)

Vote on the inclusion of an attribute accessor.

Parameters
method the accessor method
beanKey the key associated with the MBean in the beans map
Returns
  • whether the method has the appropriate metadata

protected boolean includeWriteAttribute (Method method, String beanKey)

Votes on the inclusion of an attribute mutator.

Parameters
method the mutator method
beanKey the key associated with the MBean in the beans map
Returns
  • whether the method has the appropriate metadata

protected void populateAttributeDescriptor (Descriptor desc, Method getter, Method setter, String beanKey)

Adds descriptor fields from the ManagedAttribute attribute or the ManagedMetric attribute to the attribute descriptor.

Parameters
desc the attribute descriptor
getter the accessor method for the attribute
setter the mutator method for the attribute
beanKey the key associated with the MBean in the beans map of the MBeanExporter

protected void populateMBeanDescriptor (Descriptor desc, Object managedBean, String beanKey)

Adds descriptor fields from the ManagedResource attribute to the MBean descriptor. Specifically, adds the currencyTimeLimit, persistPolicy, persistPeriod, persistLocation and persistName descriptor fields if they are present in the metadata.

Parameters
desc 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

protected void populateOperationDescriptor (Descriptor desc, Method method, String beanKey)

Adds descriptor fields from the ManagedAttribute attribute to the attribute descriptor. Specifically, adds the currencyTimeLimit descriptor field if it is present in the metadata.

Parameters
desc the operation descriptor
method the method corresponding to the operation
beanKey the key associated with the MBean in the beans map of the MBeanExporter