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
ConstructorsConstructorDescriptionCreate a newMetadataMBeanInfoAssemblerwhich needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)method.MetadataMBeanInfoAssembler(JmxAttributeSource attributeSource) Create a newMetadataMBeanInfoAssemblerfor the givenJmxAttributeSource. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.protected voidcheckManagedBean(Object managedBean) Throws an IllegalArgumentException if it encounters a JDK dynamic proxy.protected StringgetAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) Creates a description for the attribute corresponding to this property descriptor.protected StringgetDescription(Object managedBean, String beanKey) Reads managed resource description from the source level metadata.protected ModelMBeanNotificationInfo[]getNotificationInfo(Object managedBean, String beanKey) Reads theManagedNotificationmetadata from theClassof the managed resource and generates and returns the correspondingModelMBeanNotificationInfometadata.protected StringgetOperationDescription(Method method, String beanKey) Retrieves the description for the suppliedMethodfrom the metadata.protected MBeanParameterInfo[]getOperationParameters(Method method, String beanKey) ReadsMBeanParameterInfofrom theManagedOperationParameterattributes attached to a method.booleanincludeBean(Class<?> beanClass, String beanName) Used for auto-detection of beans.protected booleanincludeOperation(Method method, String beanKey) Votes on the inclusion of an operation.protected booleanincludeReadAttribute(Method method, String beanKey) Vote on the inclusion of an attribute accessor.protected booleanincludeWriteAttribute(Method method, String beanKey) Votes on the inclusion of an attribute mutator.protected voidpopulateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey) Adds descriptor fields from theManagedAttributeattribute or theManagedMetricattribute to the attribute descriptor.protected voidpopulateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) Adds descriptor fields from theManagedResourceattribute to the MBean descriptor.protected voidpopulateOperationDescriptor(Descriptor desc, Method method, String beanKey) Adds descriptor fields from theManagedAttributeattribute to the attribute descriptor.voidsetAttributeSource(JmxAttributeSource attributeSource) Set theJmxAttributeSourceimplementation 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, setUseStrictCasingMethods inherited from class org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
getClassName, getClassToExpose, getClassToExpose, getConstructorInfo, getMBeanInfo, getTargetClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.jmx.export.assembler.MBeanInfoAssembler
getMBeanInfo
-
Constructor Details
-
MetadataMBeanInfoAssembler
public MetadataMBeanInfoAssembler()Create a newMetadataMBeanInfoAssemblerwhich needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)method. -
MetadataMBeanInfoAssembler
Create a newMetadataMBeanInfoAssemblerfor the givenJmxAttributeSource.- Parameters:
attributeSource- the JmxAttributeSource to use
-
-
Method Details
-
setAttributeSource
Set theJmxAttributeSourceimplementation to use for reading the metadata from the bean class.- See Also:
-
afterPropertiesSet
public void afterPropertiesSet()Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.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:
afterPropertiesSetin interfaceInitializingBean
-
checkManagedBean
Throws an IllegalArgumentException if it encounters a JDK dynamic proxy. Metadata can only be read from target classes and CGLIB proxies!- Overrides:
checkManagedBeanin 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 auto-detection of beans. Checks to see if the bean's class has aManagedResourceattribute. If so, it will add it to the list of included beans.- Specified by:
includeBeanin 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:
includeReadAttributein 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:
includeWriteAttributein 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:
includeOperationin 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 emptyStringif no description can be found.- Overrides:
getDescriptionin 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:
getAttributeDescriptionin 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 suppliedMethodfrom the metadata. Uses the method name is no description is present in the metadata.- Overrides:
getOperationDescriptionin 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
ReadsMBeanParameterInfofrom theManagedOperationParameterattributes attached to a method. Returns an empty array ofMBeanParameterInfoif no attributes are found.- Overrides:
getOperationParametersin classAbstractReflectiveMBeanInfoAssembler- Parameters:
method- theMethodto get the parameter information forbeanKey- the key associated with the MBean in the beans map of theMBeanExporter- Returns:
- the
MBeanParameterInfoarray
-
getNotificationInfo
Reads theManagedNotificationmetadata from theClassof the managed resource and generates and returns the correspondingModelMBeanNotificationInfometadata.- Overrides:
getNotificationInfoin 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 theManagedResourceattribute to the MBean descriptor. Specifically, adds thecurrencyTimeLimit,persistPolicy,persistPeriod,persistLocationandpersistNamedescriptor fields if they are present in the metadata.- Overrides:
populateMBeanDescriptorin classAbstractReflectiveMBeanInfoAssembler- Parameters:
desc- theDescriptorfor 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 theManagedAttributeattribute or theManagedMetricattribute to the attribute descriptor.- Overrides:
populateAttributeDescriptorin 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 theManagedAttributeattribute to the attribute descriptor. Specifically, adds thecurrencyTimeLimitdescriptor field if it is present in the metadata.- Overrides:
populateOperationDescriptorin 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:
-