类 AbstractReflectiveMBeanInfoAssembler
- java.lang.Object
- org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
- org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
- 所有已实现的接口:
MBeanInfoAssembler
public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBeanInfoAssembler
Builds on theAbstractMBeanInfoAssembler
superclass to add a basic algorithm for building metadata based on the reflective metadata of the MBean class.The logic for creating MBean metadata from the reflective metadata is contained in this class, but this class makes no decisions as to which methods and properties are to be exposed. Instead it gives subclasses a chance to 'vote' on each property or method through the
includeXXX
methods.Subclasses are also given the opportunity to populate attribute and operation metadata with additional descriptors once the metadata is assembled through the
populateXXXDescriptor
methods.- 从以下版本开始:
- 1.2
- 作者:
- Rob Harrop, Juergen Hoeller, David Boden
- 另请参阅:
includeOperation(java.lang.reflect.Method, java.lang.String)
,includeReadAttribute(java.lang.reflect.Method, java.lang.String)
,includeWriteAttribute(java.lang.reflect.Method, java.lang.String)
,populateAttributeDescriptor(javax.management.Descriptor, java.lang.reflect.Method, java.lang.reflect.Method, java.lang.String)
,populateOperationDescriptor(javax.management.Descriptor, java.lang.reflect.Method, java.lang.String)
字段概要
字段 修饰符和类型 字段 说明 protected static int
ATTRIBUTE_OPERATION_VISIBILITY
Lowest visibility, used for operations that correspond to accessors or mutators for attributes.protected static String
FIELD_CLASS
Constant identifier for the class field in a JMXDescriptor
.protected static String
FIELD_CURRENCY_TIME_LIMIT
Constant identifier for the currency time limit field in a JMXDescriptor
.protected static String
FIELD_DEFAULT
Constant identifier for the default field in a JMXDescriptor
.protected static String
FIELD_DISPLAY_NAME
Constant identifier for the displayName field in a JMXDescriptor
.protected static String
FIELD_GET_METHOD
Identifies a getter method in a JMXDescriptor
.protected static String
FIELD_LOG
Constant identifier for the log field in a JMXDescriptor
.protected static String
FIELD_LOG_FILE
Constant identifier for the logfile field in a JMXDescriptor
.protected static String
FIELD_METRIC_CATEGORY
Constant identifier for the custom metricCategory field in a JMXDescriptor
.protected static String
FIELD_METRIC_TYPE
Constant identifier for the metricType field in a JMXDescriptor
.protected static String
FIELD_PERSIST_LOCATION
Constant identifier for the persistLocation field in a JMXDescriptor
.protected static String
FIELD_PERSIST_NAME
Constant identifier for the persistName field in a JMXDescriptor
.protected static String
FIELD_PERSIST_PERIOD
Constant identifier for the persistPeriod field in a JMXDescriptor
.protected static String
FIELD_PERSIST_POLICY
Constant identifier for the persistPolicy field in a JMXDescriptor
.protected static String
FIELD_ROLE
Constant identifier for the role field in a JMXDescriptor
.protected static String
FIELD_SET_METHOD
Identifies a setter method in a JMXDescriptor
.protected static String
FIELD_UNITS
Constant identifier for the units field in a JMXDescriptor
.protected static String
FIELD_VISIBILITY
Constant identifier for the visibility field in a JMXDescriptor
.protected static String
ROLE_GETTER
Constant identifier for the getter role field value in a JMXDescriptor
.protected static String
ROLE_OPERATION
Identifies an operation (method) in a JMXDescriptor
.protected static String
ROLE_SETTER
Constant identifier for the setter role field value in a JMXDescriptor
.
构造器概要
构造器 构造器 说明 AbstractReflectiveMBeanInfoAssembler()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected void
applyCurrencyTimeLimit(Descriptor desc, int currencyTimeLimit)
Apply the given JMX "currencyTimeLimit" value to the given descriptor.protected void
applyDefaultCurrencyTimeLimit(Descriptor desc)
Set thecurrencyTimeLimit
field to the specified "defaultCurrencyTimeLimit", if any (by default none).protected ModelMBeanOperationInfo
createModelMBeanOperationInfo(Method method, String name, String beanKey)
Creates an instance ofModelMBeanOperationInfo
for the given method.protected String
getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey)
Get the description for a particular attribute.protected ModelMBeanAttributeInfo[]
getAttributeInfo(Object managedBean, String beanKey)
Iterate through all properties on the MBean class and gives subclasses the chance to vote on the inclusion of both the accessor and mutator.protected Class<?>
getClassForDescriptor(Object managedBean)
Return the class to be used for the JMX descriptor field "class".protected Integer
getDefaultCurrencyTimeLimit()
Return default value for the JMX field "currencyTimeLimit", if any.protected String
getOperationDescription(Method method, String beanKey)
Get the description for a particular operation.protected ModelMBeanOperationInfo[]
getOperationInfo(Object managedBean, String beanKey)
Iterate through all methods on the MBean class and gives subclasses the chance to vote on their inclusion.protected MBeanParameterInfo[]
getOperationParameters(Method method, String beanKey)
Create parameter info for the given method.protected ParameterNameDiscoverer
getParameterNameDiscoverer()
Return the ParameterNameDiscoverer to use for resolving method parameter names if needed (may benull
in order to skip parameter detection).protected abstract boolean
includeOperation(Method method, String beanKey)
Allows subclasses to vote on the inclusion of a particular operation.protected abstract boolean
includeReadAttribute(Method method, String beanKey)
Allows subclasses to vote on the inclusion of a particular attribute accessor.protected abstract boolean
includeWriteAttribute(Method method, String beanKey)
Allows subclasses to vote on the inclusion of a particular attribute mutator.protected boolean
isExposeClassDescriptor()
Return whether to expose the JMX descriptor field "class" for managed operations.protected boolean
isUseStrictCasing()
Return whether strict casing for attributes is enabled.protected void
populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey)
Allows subclasses to add extra fields to theDescriptor
for a particular attribute.protected void
populateMBeanDescriptor(Descriptor descriptor, Object managedBean, String beanKey)
Allows subclasses to add extra fields to theDescriptor
for an MBean.protected void
populateOperationDescriptor(Descriptor desc, Method method, String beanKey)
Allows subclasses to add extra fields to theDescriptor
for a particular operation.void
setDefaultCurrencyTimeLimit(Integer defaultCurrencyTimeLimit)
Set the default for the JMX field "currencyTimeLimit".void
setExposeClassDescriptor(boolean exposeClassDescriptor)
Set whether to expose the JMX descriptor field "class" for managed operations.void
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer to use for resolving method parameter names if needed (e.g. for parameter names of MBean operation methods).void
setUseStrictCasing(boolean useStrictCasing)
Set whether to use strict casing for attributes.从类继承的方法 org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler
checkManagedBean, getClassName, getClassToExpose, getClassToExpose, getConstructorInfo, getDescription, getMBeanInfo, getNotificationInfo, getTargetClass
字段详细资料
FIELD_GET_METHOD
protected static final String FIELD_GET_METHOD
Identifies a getter method in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_SET_METHOD
protected static final String FIELD_SET_METHOD
Identifies a setter method in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_ROLE
protected static final String FIELD_ROLE
Constant identifier for the role field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
ROLE_GETTER
protected static final String ROLE_GETTER
Constant identifier for the getter role field value in a JMXDescriptor
.- 另请参阅:
- 常量字段值
ROLE_SETTER
protected static final String ROLE_SETTER
Constant identifier for the setter role field value in a JMXDescriptor
.- 另请参阅:
- 常量字段值
ROLE_OPERATION
protected static final String ROLE_OPERATION
Identifies an operation (method) in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_VISIBILITY
protected static final String FIELD_VISIBILITY
Constant identifier for the visibility field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
ATTRIBUTE_OPERATION_VISIBILITY
protected static final int ATTRIBUTE_OPERATION_VISIBILITY
Lowest visibility, used for operations that correspond to accessors or mutators for attributes.- 另请参阅:
FIELD_VISIBILITY
, 常量字段值
FIELD_CLASS
protected static final String FIELD_CLASS
Constant identifier for the class field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_LOG
protected static final String FIELD_LOG
Constant identifier for the log field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_LOG_FILE
protected static final String FIELD_LOG_FILE
Constant identifier for the logfile field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_CURRENCY_TIME_LIMIT
protected static final String FIELD_CURRENCY_TIME_LIMIT
Constant identifier for the currency time limit field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_DEFAULT
protected static final String FIELD_DEFAULT
Constant identifier for the default field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_PERSIST_POLICY
protected static final String FIELD_PERSIST_POLICY
Constant identifier for the persistPolicy field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_PERSIST_PERIOD
protected static final String FIELD_PERSIST_PERIOD
Constant identifier for the persistPeriod field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_PERSIST_LOCATION
protected static final String FIELD_PERSIST_LOCATION
Constant identifier for the persistLocation field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_PERSIST_NAME
protected static final String FIELD_PERSIST_NAME
Constant identifier for the persistName field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_DISPLAY_NAME
protected static final String FIELD_DISPLAY_NAME
Constant identifier for the displayName field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_UNITS
protected static final String FIELD_UNITS
Constant identifier for the units field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_METRIC_TYPE
protected static final String FIELD_METRIC_TYPE
Constant identifier for the metricType field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
FIELD_METRIC_CATEGORY
protected static final String FIELD_METRIC_CATEGORY
Constant identifier for the custom metricCategory field in a JMXDescriptor
.- 另请参阅:
- 常量字段值
构造器详细资料
AbstractReflectiveMBeanInfoAssembler
public AbstractReflectiveMBeanInfoAssembler()
方法详细资料
setDefaultCurrencyTimeLimit
public void setDefaultCurrencyTimeLimit(Integer defaultCurrencyTimeLimit)
Set the default for the JMX field "currencyTimeLimit". The default will usually indicate to never cache attribute values.Default is none, not explicitly setting that field, as recommended by the JMX 1.2 specification. This should result in "never cache" behavior, always reading attribute values freshly (which corresponds to a "currencyTimeLimit" of
-1
in JMX 1.2).However, some JMX implementations (that do not follow the JMX 1.2 spec in that respect) might require an explicit value to be set here to get "never cache" behavior: for example, JBoss 3.2.x.
Note that the "currencyTimeLimit" value can also be specified on a managed attribute or operation. The default value will apply if not overridden with a "currencyTimeLimit" value
>= 0
there: a metadata "currencyTimeLimit" value of-1
indicates to use the default; a value of0
indicates to "always cache" and will be translated toInteger.MAX_VALUE
; a positive value indicates the number of cache seconds.
getDefaultCurrencyTimeLimit
protected Integer getDefaultCurrencyTimeLimit()
Return default value for the JMX field "currencyTimeLimit", if any.
setUseStrictCasing
public void setUseStrictCasing(boolean useStrictCasing)
Set whether to use strict casing for attributes. Enabled by default.When using strict casing, a JavaBean property with a getter such as
getFoo()
translates to an attribute calledFoo
. With strict casing disabled,getFoo()
would translate to justfoo
.
isUseStrictCasing
protected boolean isUseStrictCasing()
Return whether strict casing for attributes is enabled.
setExposeClassDescriptor
public void setExposeClassDescriptor(boolean exposeClassDescriptor)
Set whether to expose the JMX descriptor field "class" for managed operations. Default is "false", letting the JMX implementation determine the actual class through reflection.Set this property to
true
for JMX implementations that require the "class" field to be specified, for example WebLogic's. In that case, Spring will expose the target class name there, in case of a plain bean instance or a CGLIB proxy. When encountering a JDK dynamic proxy, the first interface implemented by the proxy will be specified.WARNING: Review your proxy definitions when exposing a JDK dynamic proxy through JMX, in particular with this property turned to
true
: the specified interface list should start with your management interface in this case, with all other interfaces following. In general, consider exposing your target bean directly or a CGLIB proxy for it instead.
isExposeClassDescriptor
protected boolean isExposeClassDescriptor()
Return whether to expose the JMX descriptor field "class" for managed operations.
setParameterNameDiscoverer
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer to use for resolving method parameter names if needed (e.g. for parameter names of MBean operation methods).Default is a
DefaultParameterNameDiscoverer
.
getParameterNameDiscoverer
protected ParameterNameDiscoverer getParameterNameDiscoverer()
Return the ParameterNameDiscoverer to use for resolving method parameter names if needed (may benull
in order to skip parameter detection).
getAttributeInfo
protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException
Iterate through all properties on the MBean class and gives subclasses the chance to vote on the inclusion of both the accessor and mutator. If a particular accessor or mutator is voted for inclusion, the appropriate metadata is assembled and passed to the subclass for descriptor population.- 指定者:
getAttributeInfo
在类中AbstractMBeanInfoAssembler
- 参数:
managedBean
- the bean instance (might be an AOP proxy)beanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
- the attribute metadata
- 抛出:
JMException
- in case of errors- 另请参阅:
populateAttributeDescriptor(javax.management.Descriptor, java.lang.reflect.Method, java.lang.reflect.Method, java.lang.String)
getOperationInfo
protected ModelMBeanOperationInfo[] getOperationInfo(Object managedBean, String beanKey)
Iterate through all methods on the MBean class and gives subclasses the chance to vote on their inclusion. If a particular method corresponds to the accessor or mutator of an attribute that is included in the management interface, then the corresponding operation is exposed with the "role" descriptor field set to the appropriate value.- 指定者:
getOperationInfo
在类中AbstractMBeanInfoAssembler
- 参数:
managedBean
- the bean instance (might be an AOP proxy)beanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
- the operation metadata
- 另请参阅:
populateOperationDescriptor(javax.management.Descriptor, java.lang.reflect.Method, java.lang.String)
createModelMBeanOperationInfo
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey)
Creates an instance ofModelMBeanOperationInfo
for the given method. Populates the parameter info for the operation.- 参数:
method
- theMethod
to create aModelMBeanOperationInfo
forname
- the logical name for the operation (method name or property name); not used by the default implementation but possibly by subclassesbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
- the
ModelMBeanOperationInfo
getClassForDescriptor
protected Class<?> getClassForDescriptor(Object managedBean)
Return the class to be used for the JMX descriptor field "class". Only applied when the "exposeClassDescriptor" property is "true".The default implementation returns the first implemented interface for a JDK proxy, and the target class else.
- 参数:
managedBean
- the bean instance (might be an AOP proxy)- 返回:
- the class to expose in the descriptor field "class"
- 另请参阅:
setExposeClassDescriptor(boolean)
,AbstractMBeanInfoAssembler.getClassToExpose(Class)
,AopProxyUtils.proxiedUserInterfaces(Object)
includeReadAttribute
protected abstract boolean includeReadAttribute(Method method, String beanKey)
Allows subclasses to vote on the inclusion of a particular attribute accessor.- 参数:
method
- the accessorMethod
beanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
true
if the accessor should be included in the management interface, otherwisefalse
includeWriteAttribute
protected abstract boolean includeWriteAttribute(Method method, String beanKey)
Allows subclasses to vote on the inclusion of a particular attribute mutator.- 参数:
method
- the mutatorMethod
.beanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
true
if the mutator should be included in the management interface, otherwisefalse
includeOperation
protected abstract boolean includeOperation(Method method, String beanKey)
Allows subclasses to vote on the inclusion of a particular operation.- 参数:
method
- the operation methodbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
- whether the operation should be included in the management interface
getAttributeDescription
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey)
Get the description for a particular attribute.The default implementation returns a description for the operation that is the name of corresponding
Method
.- 参数:
propertyDescriptor
- the PropertyDescriptor for the attributebeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
- the description for the attribute
getOperationDescription
protected String getOperationDescription(Method method, String beanKey)
Get the description for a particular operation.The default implementation returns a description for the operation that is the name of corresponding
Method
.- 参数:
method
- the operation methodbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
- the description for the operation
getOperationParameters
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey)
Create parameter info for the given method.The default implementation returns an empty array of
MBeanParameterInfo
.- 参数:
method
- theMethod
to get the parameter information forbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 返回:
- the
MBeanParameterInfo
array
populateMBeanDescriptor
protected void populateMBeanDescriptor(Descriptor descriptor, Object managedBean, String beanKey)
Allows subclasses to add extra fields to theDescriptor
for an MBean.The default implementation sets the
currencyTimeLimit
field to the specified "defaultCurrencyTimeLimit", if any (by default none).- 覆盖:
populateMBeanDescriptor
在类中AbstractMBeanInfoAssembler
- 参数:
descriptor
- 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
- 另请参阅:
setDefaultCurrencyTimeLimit(Integer)
,applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
populateAttributeDescriptor
protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey)
Allows subclasses to add extra fields to theDescriptor
for a particular attribute.The default implementation sets the
currencyTimeLimit
field to the specified "defaultCurrencyTimeLimit", if any (by default none).- 参数:
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
- 另请参阅:
setDefaultCurrencyTimeLimit(Integer)
,applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
populateOperationDescriptor
protected void populateOperationDescriptor(Descriptor desc, Method method, String beanKey)
Allows subclasses to add extra fields to theDescriptor
for a particular operation.The default implementation sets the
currencyTimeLimit
field to the specified "defaultCurrencyTimeLimit", if any (by default none).- 参数:
desc
- the operation descriptormethod
- the method corresponding to the operationbeanKey
- the key associated with the MBean in the beans map of theMBeanExporter
- 另请参阅:
setDefaultCurrencyTimeLimit(Integer)
,applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
applyDefaultCurrencyTimeLimit
protected final void applyDefaultCurrencyTimeLimit(Descriptor desc)
Set thecurrencyTimeLimit
field to the specified "defaultCurrencyTimeLimit", if any (by default none).- 参数:
desc
- the JMX attribute or operation descriptor- 另请参阅:
setDefaultCurrencyTimeLimit(Integer)
applyCurrencyTimeLimit
protected void applyCurrencyTimeLimit(Descriptor desc, int currencyTimeLimit)
Apply the given JMX "currencyTimeLimit" value to the given descriptor.The default implementation sets a value
>0
as-is (as number of cache seconds), turns a value of0
intoInteger.MAX_VALUE
("always cache") and sets the "defaultCurrencyTimeLimit" (if any, indicating "never cache") in case of a value<0
. This follows the recommendation in the JMX 1.2 specification.- 参数:
desc
- the JMX attribute or operation descriptorcurrencyTimeLimit
- the "currencyTimeLimit" value to apply- 另请参阅:
setDefaultCurrencyTimeLimit(Integer)
,applyDefaultCurrencyTimeLimit(javax.management.Descriptor)