Class MetadataMBeanInfoAssembler
java.lang.Object
org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler
- All Implemented Interfaces:
InitializingBean
,AutodetectCapableMBeanInfoAssembler
,MBeanInfoAssembler
public class MetadataMBeanInfoAssembler
extends AbstractReflectiveMBeanInfoAssembler
implements AutodetectCapableMBeanInfoAssembler, InitializingBean
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
.
- Since:
- 1.2
- Author:
- Rob Harrop, Juergen Hoeller, Jennifer Hickey
- See Also:
-
Field Summary
Fields inherited from class org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
ATTRIBUTE_OPERATION_VISIBILITY, FIELD_CLASS, FIELD_CURRENCY_TIME_LIMIT, FIELD_DEFAULT, FIELD_DISPLAY_NAME, FIELD_GET_METHOD, FIELD_LOG, FIELD_LOG_FILE, FIELD_METRIC_CATEGORY, FIELD_METRIC_TYPE, FIELD_PERSIST_LOCATION, FIELD_PERSIST_NAME, FIELD_PERSIST_PERIOD, FIELD_PERSIST_POLICY, FIELD_ROLE, FIELD_SET_METHOD, FIELD_UNITS, FIELD_VISIBILITY, ROLE_GETTER, ROLE_OPERATION, ROLE_SETTER
-
Constructor Summary
ConstructorDescriptionCreate a newMetadataMBeanInfoAssembler
which needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)
method.MetadataMBeanInfoAssembler
(JmxAttributeSource attributeSource) Create a newMetadataMBeanInfoAssembler
for the givenJmxAttributeSource
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.protected void
checkManagedBean
(Object managedBean) Throws an IllegalArgumentException if it encounters a JDK dynamic proxy.protected String
getAttributeDescription
(PropertyDescriptor propertyDescriptor, String beanKey) Creates a description for the attribute corresponding to this property descriptor.protected String
getDescription
(Object managedBean, String beanKey) Reads managed resource description from the source level metadata.protected ModelMBeanNotificationInfo[]
getNotificationInfo
(Object managedBean, String beanKey) Reads theManagedNotification
metadata from theClass
of the managed resource and generates and returns the correspondingModelMBeanNotificationInfo
metadata.protected String
getOperationDescription
(Method method, String beanKey) Retrieves the description for the suppliedMethod
from the metadata.protected MBeanParameterInfo[]
getOperationParameters
(Method method, String beanKey) ReadsMBeanParameterInfo
from theManagedOperationParameter
attributes attached to a method.boolean
includeBean
(Class<?> beanClass, String beanName) Used for autodetection of beans.protected boolean
includeOperation
(Method method, String beanKey) Votes on the inclusion of an operation.protected boolean
includeReadAttribute
(Method method, String beanKey) Vote on the inclusion of an attribute accessor.protected boolean
includeWriteAttribute
(Method method, String beanKey) Votes on the inclusion of an attribute mutator.protected void
populateAttributeDescriptor
(Descriptor desc, Method getter, Method setter, String beanKey) Adds descriptor fields from theManagedAttribute
attribute or theManagedMetric
attribute to the attribute descriptor.protected void
populateMBeanDescriptor
(Descriptor desc, Object managedBean, String beanKey) Adds descriptor fields from theManagedResource
attribute to the MBean descriptor.protected void
populateOperationDescriptor
(Descriptor desc, Method method, String beanKey) Adds descriptor fields from theManagedAttribute
attribute to the attribute descriptor.void
setAttributeSource
(JmxAttributeSource attributeSource) Set theJmxAttributeSource
implementation to use for reading the metadata from the bean class.Methods inherited from class org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
applyCurrencyTimeLimit, applyDefaultCurrencyTimeLimit, createModelMBeanOperationInfo, getAttributeInfo, getClassForDescriptor, getDefaultCurrencyTimeLimit, getOperationInfo, getParameterNameDiscoverer, isExposeClassDescriptor, isUseStrictCasing, setDefaultCurrencyTimeLimit, setExposeClassDescriptor, setParameterNameDiscoverer, setUseStrictCasing
Methods inherited from class org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
getClassName, getClassToExpose, getClassToExpose, getConstructorInfo, getMBeanInfo, getTargetClass
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.jmx.export.assembler.MBeanInfoAssembler
getMBeanInfo
-
Constructor Details
-
MetadataMBeanInfoAssembler
public MetadataMBeanInfoAssembler()Create a newMetadataMBeanInfoAssembler
which needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)
method. -
MetadataMBeanInfoAssembler
Create a newMetadataMBeanInfoAssembler
for the givenJmxAttributeSource
.- Parameters:
attributeSource
- the JmxAttributeSource to use
-
-
Method Details
-
setAttributeSource
Set theJmxAttributeSource
implementation to use for reading the metadata from the bean class.- See Also:
-
afterPropertiesSet
public void afterPropertiesSet()Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,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 interfaceInitializingBean
-
checkManagedBean
Throws an IllegalArgumentException if it encounters a JDK dynamic proxy. Metadata can only be read from target classes and CGLIB proxies!- Overrides:
checkManagedBean
in classAbstractMBeanInfoAssembler
- Parameters:
managedBean
- the bean that will be exposed (might be an AOP proxy)- Throws:
IllegalArgumentException
- the bean is not valid for exposure
-
includeBean
Used for autodetection of beans. Checks to see if the bean's class has aManagedResource
attribute. If so, it will add it to the list of included beans.- Specified by:
includeBean
in interfaceAutodetectCapableMBeanInfoAssembler
- Parameters:
beanClass
- the class of the beanbeanName
- the name of the bean in the bean factory
-
includeReadAttribute
Vote on the inclusion of an attribute accessor.- Specified by:
includeReadAttribute
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
method
- the accessor methodbeanKey
- the key associated with the MBean in the beans map- Returns:
- whether the method has the appropriate metadata
-
includeWriteAttribute
Votes on the inclusion of an attribute mutator.- Specified by:
includeWriteAttribute
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
method
- the mutator methodbeanKey
- the key associated with the MBean in the beans map- Returns:
- whether the method has the appropriate metadata
-
includeOperation
Votes on the inclusion of an operation.- Specified by:
includeOperation
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
method
- the operation methodbeanKey
- the key associated with the MBean in the beans map- Returns:
- whether the method has the appropriate metadata
-
getDescription
Reads managed resource description from the source level metadata. Returns an emptyString
if no description can be found.- Overrides:
getDescription
in classAbstractMBeanInfoAssembler
- Parameters:
managedBean
- the bean instance (might be an AOP proxy)beanKey
- the key associated with the MBean in the beans map of theMBeanExporter
-
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.- Overrides:
getAttributeDescription
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
propertyDescriptor
- the PropertyDescriptor for the attributebeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- Returns:
- the description for the attribute
-
getOperationDescription
Retrieves the description for the suppliedMethod
from the metadata. Uses the method name is no description is present in the metadata.- Overrides:
getOperationDescription
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
method
- the operation methodbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- Returns:
- the description for the operation
-
getOperationParameters
ReadsMBeanParameterInfo
from theManagedOperationParameter
attributes attached to a method. Returns an empty array ofMBeanParameterInfo
if no attributes are found.- Overrides:
getOperationParameters
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
method
- theMethod
to get the parameter information forbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- Returns:
- the
MBeanParameterInfo
array
-
getNotificationInfo
Reads theManagedNotification
metadata from theClass
of the managed resource and generates and returns the correspondingModelMBeanNotificationInfo
metadata.- Overrides:
getNotificationInfo
in classAbstractMBeanInfoAssembler
- Parameters:
managedBean
- the bean instance (might be an AOP proxy)beanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- Returns:
- the notification metadata
-
populateMBeanDescriptor
Adds descriptor fields from theManagedResource
attribute to the MBean descriptor. Specifically, adds thecurrencyTimeLimit
,persistPolicy
,persistPeriod
,persistLocation
andpersistName
descriptor fields if they are present in the metadata.- Overrides:
populateMBeanDescriptor
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
desc
- theDescriptor
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 theMBeanExporter
- See Also:
-
populateAttributeDescriptor
protected void populateAttributeDescriptor(Descriptor desc, @Nullable Method getter, @Nullable Method setter, String beanKey) Adds descriptor fields from theManagedAttribute
attribute or theManagedMetric
attribute to the attribute descriptor.- Overrides:
populateAttributeDescriptor
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
desc
- the attribute descriptorgetter
- the accessor method for the attributesetter
- the mutator method for the attributebeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- See Also:
-
populateOperationDescriptor
Adds descriptor fields from theManagedAttribute
attribute to the attribute descriptor. Specifically, adds thecurrencyTimeLimit
descriptor field if it is present in the metadata.- Overrides:
populateOperationDescriptor
in classAbstractReflectiveMBeanInfoAssembler
- Parameters:
desc
- the operation descriptormethod
- the method corresponding to the operationbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- See Also:
-