Top Description Fields Constructors Methods
org.springframework.jmx.export.assembler

public Class MetadataMBeanInfoAssembler

extends AbstractReflectiveMBeanInfoAssembler
implements AutodetectCapableMBeanInfoAssembler, InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean, org.springframework.jmx.export.assembler.AutodetectCapableMBeanInfoAssembler, org.springframework.jmx.export.assembler.MBeanInfoAssembler
Imports
java.beans.PropertyDescriptor, java.lang.reflect.Method, javax.management.Descriptor, .MBeanParameterInfo, javax.management.modelmbean.ModelMBeanNotificationInfo, org.springframework.aop.support.AopUtils, org.springframework.beans.BeanUtils, org.springframework.beans.factory.InitializingBean, org.springframework.jmx.export.metadata.InvalidMetadataException, .JmxAttributeSource, .JmxMetadataUtils, .ManagedAttribute, .ManagedMetric, .ManagedNotification, .ManagedOperation, .ManagedOperationParameter, .ManagedResource, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils, .StringUtils

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 annotations: AnnotationJmxAttributeSource.

Authors
Rob Harrop, Juergen Hoeller, Jennifer Hickey
Since
1.2
See Also
setAttributeSource, org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource

Field Summary

Modifier and TypeField and Description
private JmxAttributeSource
Inherited from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler:
ATTRIBUTE_OPERATION_VISIBILITYFIELD_CLASSFIELD_CURRENCY_TIME_LIMITFIELD_DEFAULTFIELD_DISPLAY_NAMEFIELD_GET_METHODFIELD_LOGFIELD_LOG_FILEFIELD_METRIC_CATEGORYFIELD_METRIC_TYPEFIELD_PERSIST_LOCATIONFIELD_PERSIST_NAMEFIELD_PERSIST_PERIODFIELD_PERSIST_POLICYFIELD_ROLEFIELD_SET_METHODFIELD_UNITSFIELD_VISIBILITYROLE_GETTERROLE_OPERATIONROLE_SETTER

Constructor Summary

AccessConstructor and Description
public
MetadataMBeanInfoAssembler()

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

public
MetadataMBeanInfoAssembler(JmxAttributeSource
the JmxAttributeSource to use
attributeSource
)

Create a new MetadataMBeanInfoAssembler for the given JmxAttributeSource.

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

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.

protected void
checkManagedBean(Object
the bean that will be exposed (might be an AOP proxy)
managedBean
)

Overrides org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.checkManagedBean.

Throws an IllegalArgumentException if it encounters a JDK dynamic proxy.
protected String
getAttributeDescription(PropertyDescriptor
the PropertyDescriptor for the attribute
propertyDescriptor
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getAttributeDescription.

Creates a description for the attribute corresponding to this property descriptor.
protected String
getDescription(Object
the bean instance (might be an AOP proxy)
managedBean
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getDescription.

Reads managed resource description from the source level metadata.
protected ModelMBeanNotificationInfo[]
getNotificationInfo(Object
the bean instance (might be an AOP proxy)
managedBean
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getNotificationInfo.

Reads the ManagedNotification metadata from the Class of the managed resource and generates and returns the corresponding ModelMBeanNotificationInfo metadata.
protected String
getOperationDescription(Method
the operation method
method
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationDescription.

Retrieves the description for the supplied Method from the metadata.
protected MBeanParameterInfo[]
getOperationParameters(Method
the Method to get the parameter information for
method
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationParameters.

Reads MBeanParameterInfo from the ManagedOperationParameter attributes attached to a method.
private boolean
hasManagedAttribute(Method method)

Checks to see if the given Method has the ManagedAttribute attribute.

private boolean
hasManagedMetric(Method method)

Checks to see if the given Method has the ManagedMetric attribute.

private boolean
hasManagedOperation(Method
the method to check
method
)

Checks to see if the given Method has the ManagedOperation attribute.

public boolean
includeBean(Class<?>
the class of the bean
beanClass
,
String
the name of the bean in the bean factory
beanName
)

Implements org.springframework.jmx.export.assembler.AutodetectCapableMBeanInfoAssembler.includeBean.

Used for auto-detection of beans.
protected boolean

Returns:

whether the method has the appropriate metadata
includeOperation
(Method
the operation method
method
,
String
the key associated with the MBean in the beans map
beanKey
)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeOperation.

Votes on the inclusion of an operation.
protected boolean

Returns:

whether the method has the appropriate metadata
includeReadAttribute
(Method
the accessor method
method
,
String
the key associated with the MBean in the beans map
beanKey
)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeReadAttribute.

Vote on the inclusion of an attribute accessor.
protected boolean

Returns:

whether the method has the appropriate metadata
includeWriteAttribute
(Method
the mutator method
method
,
String
the key associated with the MBean in the beans map
beanKey
)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeWriteAttribute.

Votes on the inclusion of an attribute mutator.
private JmxAttributeSource
protected void
populateAttributeDescriptor(Descriptor
the attribute descriptor
desc
,
Method
the accessor method for the attribute
getter
,
Method
the mutator method for the attribute
setter
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateAttributeDescriptor.

Adds descriptor fields from the ManagedAttribute attribute or the ManagedMetric attribute to the attribute descriptor.
private void
protected void
populateMBeanDescriptor(Descriptor
the Descriptor for the MBean resource.
desc
,
Object
the bean instance (might be an AOP proxy)
managedBean
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateMBeanDescriptor.

Adds descriptor fields from the ManagedResource attribute to the MBean descriptor.
private void
protected void
populateOperationDescriptor(Descriptor
the operation descriptor
desc
,
Method
the method corresponding to the operation
method
,
String
the key associated with the MBean in the beans map of the MBeanExporter
beanKey
)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateOperationDescriptor.

Adds descriptor fields from the ManagedAttribute attribute to the attribute descriptor.
private int
resolveIntDescriptor(int
the int value associated with the getter for this attribute
getter
,
int
the int associated with the setter for this attribute
setter
)

Determines which of two int values should be used as the value for an attribute descriptor.

private Object

Returns:

the appropriate Object to use as the value for the descriptor
resolveObjectDescriptor
(Object
the Object value associated with the get method
getter
,
Object
the Object value associated with the set method
setter
)

Locates the value of a descriptor based on values attached to both the getter and setter methods.

private String

Returns:

the appropriate String to use as the value for the descriptor
resolveStringDescriptor
(String
the String value associated with the get method
getter
,
String
the String value associated with the set method
setter
)

Locates the value of a descriptor based on values attached to both the getter and setter methods.

public void
setAttributeSource(JmxAttributeSource attributeSource)

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

Inherited from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler:
applyCurrencyTimeLimitapplyDefaultCurrencyTimeLimitcreateModelMBeanOperationInfogetAttributeInfogetClassForDescriptorgetDefaultCurrencyTimeLimitgetOperationInfogetParameterNameDiscovererisExposeClassDescriptorisUseStrictCasingsetDefaultCurrencyTimeLimitsetExposeClassDescriptorsetParameterNameDiscoverersetUseStrictCasing

Field Detail

attributeSourceback to summary
private JmxAttributeSource attributeSource
Annotations
@Nullable

Constructor Detail

MetadataMBeanInfoAssemblerback to summary
public MetadataMBeanInfoAssembler()

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

MetadataMBeanInfoAssemblerback to summary
public MetadataMBeanInfoAssembler(JmxAttributeSource attributeSource)

Create a new MetadataMBeanInfoAssembler for the given JmxAttributeSource.

Parameters
attributeSource:JmxAttributeSource

the JmxAttributeSource to use

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

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.

Annotations
@Override
checkManagedBeanback to summary
protected void checkManagedBean(Object managedBean) throws IllegalArgumentException

Overrides org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.checkManagedBean.

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

Parameters
managedBean:Object

Doc from org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.checkManagedBean.

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

Annotations
@Override
Exceptions
IllegalArgumentException:

Doc from org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.checkManagedBean.

the bean is not valid for exposure

getAttributeDescriptionback to summary
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getAttributeDescription.

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:PropertyDescriptor

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getAttributeDescription.

the PropertyDescriptor for the attribute

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getAttributeDescription.

the key associated with the MBean in the beans map of the MBeanExporter

Returns:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getAttributeDescription.

the description for the attribute

Annotations
@Override
getDescriptionback to summary
protected String getDescription(Object managedBean, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getDescription.

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

Parameters
managedBean:Object

Doc from org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getDescription.

the bean instance (might be an AOP proxy)

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getDescription.

the key associated with the MBean in the beans map of the MBeanExporter

Annotations
@Override
getNotificationInfoback to summary
protected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getNotificationInfo.

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

Parameters
managedBean:Object

Doc from org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getNotificationInfo.

the bean instance (might be an AOP proxy)

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getNotificationInfo.

the key associated with the MBean in the beans map of the MBeanExporter

Returns:ModelMBeanNotificationInfo[]

Doc from org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler.getNotificationInfo.

the notification metadata

Annotations
@Override
getOperationDescriptionback to summary
protected String getOperationDescription(Method method, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationDescription.

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

Parameters
method:Method

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationDescription.

the operation method

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationDescription.

the key associated with the MBean in the beans map of the MBeanExporter

Returns:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationDescription.

the description for the operation

Annotations
@Override
getOperationParametersback to summary
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationParameters.

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

Parameters
method:Method

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationParameters.

the Method to get the parameter information for

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationParameters.

the key associated with the MBean in the beans map of the MBeanExporter

Returns:MBeanParameterInfo[]

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.getOperationParameters.

the MBeanParameterInfo array

Annotations
@Override
hasManagedAttributeback to summary
private boolean hasManagedAttribute(Method method)

Checks to see if the given Method has the ManagedAttribute attribute.

hasManagedMetricback to summary
private boolean hasManagedMetric(Method method)

Checks to see if the given Method has the ManagedMetric attribute.

hasManagedOperationback to summary
private boolean hasManagedOperation(Method method)

Checks to see if the given Method has the ManagedOperation attribute.

Parameters
method:Method

the method to check

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

Implements org.springframework.jmx.export.assembler.AutodetectCapableMBeanInfoAssembler.includeBean.

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

Parameters
beanClass:Class<?>

the class of the bean

beanName:String

the name of the bean in the bean factory

Annotations
@Override
includeOperationback to summary
protected boolean includeOperation(Method method, String beanKey)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeOperation.

Votes on the inclusion of an operation.

Parameters
method:Method

the operation method

beanKey:String

the key associated with the MBean in the beans map

Returns:boolean

whether the method has the appropriate metadata

Annotations
@Override
includeReadAttributeback to summary
protected boolean includeReadAttribute(Method method, String beanKey)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeReadAttribute.

Vote on the inclusion of an attribute accessor.

Parameters
method:Method

the accessor method

beanKey:String

the key associated with the MBean in the beans map

Returns:boolean

whether the method has the appropriate metadata

Annotations
@Override
includeWriteAttributeback to summary
protected boolean includeWriteAttribute(Method method, String beanKey)

Implements abstract org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.includeWriteAttribute.

Votes on the inclusion of an attribute mutator.

Parameters
method:Method

the mutator method

beanKey:String

the key associated with the MBean in the beans map

Returns:boolean

whether the method has the appropriate metadata

Annotations
@Override
obtainAttributeSourceback to summary
private JmxAttributeSource obtainAttributeSource()
populateAttributeDescriptorback to summary
protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateAttributeDescriptor.

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

Parameters
desc:Descriptor

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateAttributeDescriptor.

the attribute descriptor

getter:Method

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateAttributeDescriptor.

the accessor method for the attribute

setter:Method

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateAttributeDescriptor.

the mutator method for the attribute

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateAttributeDescriptor.

the key associated with the MBean in the beans map of the MBeanExporter

Annotations
@Override
populateAttributeDescriptorback to summary
private void populateAttributeDescriptor(Descriptor desc, ManagedAttribute gma, ManagedAttribute sma)
populateMBeanDescriptorback to summary
protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateMBeanDescriptor.

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:Descriptor

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateMBeanDescriptor.

the Descriptor for the MBean resource.

managedBean:Object

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateMBeanDescriptor.

the bean instance (might be an AOP proxy)

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateMBeanDescriptor.

the key associated with the MBean in the beans map of the MBeanExporter

Annotations
@Override
populateMetricDescriptorback to summary
private void populateMetricDescriptor(Descriptor desc, ManagedMetric metric)
populateOperationDescriptorback to summary
protected void populateOperationDescriptor(Descriptor desc, Method method, String beanKey)

Overrides org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateOperationDescriptor.

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:Descriptor

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateOperationDescriptor.

the operation descriptor

method:Method

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateOperationDescriptor.

the method corresponding to the operation

beanKey:String

Doc from org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler.populateOperationDescriptor.

the key associated with the MBean in the beans map of the MBeanExporter

Annotations
@Override
resolveIntDescriptorback to summary
private int resolveIntDescriptor(int getter, int setter)

Determines which of two int values should be used as the value for an attribute descriptor. In general, only the getter or the setter will have a non-negative value, so we use that value. In the event that both values are non-negative, we use the greater of the two. This method can be used to resolve any int valued descriptor where there are two possible values.

Parameters
getter:int

the int value associated with the getter for this attribute

setter:int

the int associated with the setter for this attribute

resolveObjectDescriptorback to summary
private Object resolveObjectDescriptor(Object getter, Object setter)

Locates the value of a descriptor based on values attached to both the getter and setter methods. If both have values supplied then the value attached to the getter is preferred.

Parameters
getter:Object

the Object value associated with the get method

setter:Object

the Object value associated with the set method

Returns:Object

the appropriate Object to use as the value for the descriptor

Annotations
@Nullable
resolveStringDescriptorback to summary
private String resolveStringDescriptor(String getter, String setter)

Locates the value of a descriptor based on values attached to both the getter and setter methods. If both have values supplied then the value attached to the getter is preferred. The supplied default value is used to check to see if the value associated with the getter has changed from the default.

Parameters
getter:String

the String value associated with the get method

setter:String

the String value associated with the set method

Returns:String

the appropriate String to use as the value for the descriptor

Annotations
@Nullable
setAttributeSourceback to summary
public void setAttributeSource(JmxAttributeSource attributeSource)

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

See Also
org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource