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 SummaryFields inherited from class org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssemblerATTRIBUTE_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 SummaryConstructorsConstructorDescriptionCreate a newMetadataMBeanInfoAssemblerwhich needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)method.MetadataMBeanInfoAssembler(JmxAttributeSource attributeSource) Create a newMetadataMBeanInfoAssemblerfor the givenJmxAttributeSource.
- 
Method SummaryModifier 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 autodetection 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.AbstractReflectiveMBeanInfoAssemblerapplyCurrencyTimeLimit, applyDefaultCurrencyTimeLimit, createModelMBeanOperationInfo, getAttributeInfo, getClassForDescriptor, getDefaultCurrencyTimeLimit, getOperationInfo, getParameterNameDiscoverer, isExposeClassDescriptor, isUseStrictCasing, setDefaultCurrencyTimeLimit, setExposeClassDescriptor, setParameterNameDiscoverer, setUseStrictCasingMethods inherited from class org.springframework.jmx.export.assembler.AbstractMBeanInfoAssemblergetClassName, getClassToExpose, getClassToExpose, getConstructorInfo, getMBeanInfo, getTargetClassMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.jmx.export.assembler.MBeanInfoAssemblergetMBeanInfo
- 
Constructor Details- 
MetadataMBeanInfoAssemblerpublic MetadataMBeanInfoAssembler()Create a newMetadataMBeanInfoAssemblerwhich needs to be configured through thesetAttributeSource(org.springframework.jmx.export.metadata.JmxAttributeSource)method.
- 
MetadataMBeanInfoAssemblerCreate a newMetadataMBeanInfoAssemblerfor the givenJmxAttributeSource.- Parameters:
- attributeSource- the JmxAttributeSource to use
 
 
- 
- 
Method Details- 
setAttributeSourceSet theJmxAttributeSourceimplementation to use for reading the metadata from the bean class.- See Also:
 
- 
afterPropertiesSetpublic 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 interface- InitializingBean
 
- 
checkManagedBeanThrows an IllegalArgumentException if it encounters a JDK dynamic proxy. Metadata can only be read from target classes and CGLIB proxies!- Overrides:
- checkManagedBeanin class- AbstractMBeanInfoAssembler
- Parameters:
- managedBean- the bean that will be exposed (might be an AOP proxy)
- Throws:
- IllegalArgumentException- the bean is not valid for exposure
 
- 
includeBeanUsed for autodetection 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 interface- AutodetectCapableMBeanInfoAssembler
- Parameters:
- beanClass- the class of the bean
- beanName- the name of the bean in the bean factory
 
- 
includeReadAttributeVote on the inclusion of an attribute accessor.- Specified by:
- includeReadAttributein class- AbstractReflectiveMBeanInfoAssembler
- Parameters:
- method- the accessor method
- beanKey- the key associated with the MBean in the beans map
- Returns:
- whether the method has the appropriate metadata
 
- 
includeWriteAttributeVotes on the inclusion of an attribute mutator.- Specified by:
- includeWriteAttributein class- AbstractReflectiveMBeanInfoAssembler
- Parameters:
- method- the mutator method
- beanKey- the key associated with the MBean in the beans map
- Returns:
- whether the method has the appropriate metadata
 
- 
includeOperationVotes on the inclusion of an operation.- Specified by:
- includeOperationin class- AbstractReflectiveMBeanInfoAssembler
- Parameters:
- method- the operation method
- beanKey- the key associated with the MBean in the beans map
- Returns:
- whether the method has the appropriate metadata
 
- 
getDescriptionReads managed resource description from the source level metadata. Returns an emptyStringif no description can be found.- Overrides:
- getDescriptionin class- AbstractMBeanInfoAssembler
- Parameters:
- managedBean- the bean instance (might be an AOP proxy)
- beanKey- the key associated with the MBean in the beans map of the- MBeanExporter
 
- 
getAttributeDescriptionCreates 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 class- AbstractReflectiveMBeanInfoAssembler
- 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
 
- 
getOperationDescriptionRetrieves the description for the suppliedMethodfrom the metadata. Uses the method name is no description is present in the metadata.- Overrides:
- getOperationDescriptionin class- AbstractReflectiveMBeanInfoAssembler
- 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
 
- 
getOperationParametersReadsMBeanParameterInfofrom theManagedOperationParameterattributes attached to a method. Returns an empty array ofMBeanParameterInfoif no attributes are found.- Overrides:
- getOperationParametersin class- AbstractReflectiveMBeanInfoAssembler
- Parameters:
- method- the- Methodto get the parameter information for
- beanKey- the key associated with the MBean in the beans map of the- MBeanExporter
- Returns:
- the MBeanParameterInfoarray
 
- 
getNotificationInfoReads theManagedNotificationmetadata from theClassof the managed resource and generates and returns the correspondingModelMBeanNotificationInfometadata.- Overrides:
- getNotificationInfoin class- AbstractMBeanInfoAssembler
- 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
 
- 
populateMBeanDescriptorAdds descriptor fields from theManagedResourceattribute to the MBean descriptor. Specifically, adds thecurrencyTimeLimit,persistPolicy,persistPeriod,persistLocationandpersistNamedescriptor fields if they are present in the metadata.- Overrides:
- populateMBeanDescriptorin class- AbstractReflectiveMBeanInfoAssembler
- Parameters:
- desc- the- Descriptorfor 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
- See Also:
 
- 
populateAttributeDescriptorprotected 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 class- AbstractReflectiveMBeanInfoAssembler
- 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
- See Also:
 
- 
populateOperationDescriptorAdds descriptor fields from theManagedAttributeattribute to the attribute descriptor. Specifically, adds thecurrencyTimeLimitdescriptor field if it is present in the metadata.- Overrides:
- populateOperationDescriptorin class- AbstractReflectiveMBeanInfoAssembler
- 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
- See Also:
 
 
-