|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler
public abstract class AbstractReflectiveMBeanInfoAssembler
Builds on the AbstractMBeanInfoAssembler
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.
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)
Field Summary | |
---|---|
protected static Integer |
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 JMX Descriptor . |
protected static String |
FIELD_CURRENCY_TIME_LIMIT
Constant identifier for the currency time limit field in a JMX Descriptor . |
protected static String |
FIELD_DEFAULT
Constant identifier for the default field in a JMX Descriptor . |
protected static String |
FIELD_GET_METHOD
Identifies a getter method in a JMX Descriptor . |
protected static String |
FIELD_LOG
Constant identifier for the log field in a JMX Descriptor . |
protected static String |
FIELD_LOG_FILE
Constant identifier for the logfile field in a JMX Descriptor . |
protected static String |
FIELD_PERSIST_LOCATION
Constant identifier for the persistLocation field in a JMX Descriptor . |
protected static String |
FIELD_PERSIST_NAME
Constant identifier for the persistName field in a JMX Descriptor . |
protected static String |
FIELD_PERSIST_PERIOD
Constant identifier for the persistPeriod field in a JMX Descriptor . |
protected static String |
FIELD_PERSIST_POLICY
Constant identifier for the persistPolicy field in a JMX Descriptor . |
protected static String |
FIELD_ROLE
Constant identifier for the role field in a JMX Descriptor . |
protected static String |
FIELD_SET_METHOD
Identifies a setter method in a JMX Descriptor . |
protected static String |
FIELD_VISIBILITY
Constant identifier for the visibility field in a JMX Descriptor . |
protected static String |
ROLE_GETTER
Constant identifier for the getter role field value in a JMX Descriptor . |
protected static String |
ROLE_OPERATION
Identifies an operation (method) in a JMX Descriptor . |
protected static String |
ROLE_SETTER
Constant identifier for the setter role field value in a JMX Descriptor . |
Constructor Summary | |
---|---|
AbstractReflectiveMBeanInfoAssembler()
|
Method Summary | |
---|---|
protected void |
applyCurrencyTimeLimit(Descriptor desc,
int currencyTimeLimit)
Apply the given JMX "currencyTimeLimit" value to the given descriptor. |
protected void |
applyDefaultCurrencyTimeLimit(Descriptor desc)
Set the currencyTimeLimit field to the specified
"defaultCurrencyTimeLimit", if any (by default none). |
protected ModelMBeanOperationInfo |
createModelMBeanOperationInfo(Method method,
String name,
String beanKey)
Creates an instance of ModelMBeanOperationInfo 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 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 the Descriptor for a particular
attribute. |
protected void |
populateMBeanDescriptor(Descriptor descriptor,
Object managedBean,
String beanKey)
Allows subclasses to add extra fields to the Descriptor for an
MBean. |
protected void |
populateOperationDescriptor(Descriptor desc,
Method method,
String beanKey)
Allows subclasses to add extra fields to the Descriptor 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 |
setUseStrictCasing(boolean useStrictCasing)
Set whether to use strict casing for attributes. |
Methods inherited from class org.springframework.jmx.export.assembler.AbstractMBeanInfoAssembler |
---|
checkManagedBean, getClassName, getClassToExpose, getClassToExpose, getConstructorInfo, getDescription, getMBeanInfo, getNotificationInfo, getTargetClass |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String FIELD_GET_METHOD
Descriptor
.
protected static final String FIELD_SET_METHOD
Descriptor
.
protected static final String FIELD_ROLE
Descriptor
.
protected static final String ROLE_GETTER
Descriptor
.
protected static final String ROLE_SETTER
Descriptor
.
protected static final String ROLE_OPERATION
Descriptor
.
protected static final String FIELD_VISIBILITY
Descriptor
.
protected static final Integer ATTRIBUTE_OPERATION_VISIBILITY
FIELD_VISIBILITY
protected static final String FIELD_CLASS
Descriptor
.
protected static final String FIELD_LOG
Descriptor
.
protected static final String FIELD_LOG_FILE
Descriptor
.
protected static final String FIELD_CURRENCY_TIME_LIMIT
Descriptor
.
protected static final String FIELD_DEFAULT
Descriptor
.
protected static final String FIELD_PERSIST_POLICY
Descriptor
.
protected static final String FIELD_PERSIST_PERIOD
Descriptor
.
protected static final String FIELD_PERSIST_LOCATION
Descriptor
.
protected static final String FIELD_PERSIST_NAME
Descriptor
.
Constructor Detail |
---|
public AbstractReflectiveMBeanInfoAssembler()
Method Detail |
---|
public void setDefaultCurrencyTimeLimit(Integer defaultCurrencyTimeLimit)
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 of 0
indicates to "always cache"
and will be translated to Integer.MAX_VALUE
; a positive
value indicates the number of cache seconds.
protected Integer getDefaultCurrencyTimeLimit()
public void setUseStrictCasing(boolean useStrictCasing)
When using strict casing, a JavaBean property with a getter such as
getFoo()
translates to an attribute called Foo
.
With strict casing disabled, getFoo()
would translate to just
foo
.
protected boolean isUseStrictCasing()
public void setExposeClassDescriptor(boolean exposeClassDescriptor)
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.
getClassForDescriptor(Object)
protected boolean isExposeClassDescriptor()
protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException
getAttributeInfo
in class AbstractMBeanInfoAssembler
managedBean
- the bean instance (might be an AOP proxy)beanKey
- the key associated with the MBean in the beans map
of the MBeanExporter
JMException
- in case of errorspopulateAttributeDescriptor(javax.management.Descriptor, java.lang.reflect.Method, java.lang.reflect.Method, java.lang.String)
protected ModelMBeanOperationInfo[] getOperationInfo(Object managedBean, String beanKey)
getOperationInfo
in class AbstractMBeanInfoAssembler
managedBean
- the bean instance (might be an AOP proxy)beanKey
- the key associated with the MBean in the beans map
of the MBeanExporter
populateOperationDescriptor(javax.management.Descriptor, java.lang.reflect.Method, java.lang.String)
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey)
ModelMBeanOperationInfo
for the
given method. Populates the parameter info for the operation.
method
- the Method
to create a ModelMBeanOperationInfo
forname
- the name for the operation infobeanKey
- the key associated with the MBean in the beans map
of the MBeanExporter
ModelMBeanOperationInfo
protected Class getClassForDescriptor(Object managedBean)
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)
setExposeClassDescriptor(boolean)
,
AbstractMBeanInfoAssembler.getClassToExpose(Class)
,
AopProxyUtils.proxiedUserInterfaces(Object)
protected abstract boolean includeReadAttribute(Method method, String beanKey)
method
- the accessor Method
beanKey
- the key associated with the MBean in the beans map
of the MBeanExporter
true
if the accessor should be included in the management interface,
otherwise false
protected abstract boolean includeWriteAttribute(Method method, String beanKey)
method
- the mutator Method
.beanKey
- the key associated with the MBean in the beans map
of the MBeanExporter
true
if the mutator should be included in the management interface,
otherwise false
protected abstract boolean includeOperation(Method method, String beanKey)
method
- the operation methodbeanKey
- the key associated with the MBean in the beans map
of the MBeanExporter
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey)
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 the MBeanExporter
protected String getOperationDescription(Method method, String beanKey)
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 the MBeanExporter
protected MBeanParameterInfo[] getOperationParameters(Method method, String beanKey)
MBeanParameterInfo
.
method
- the Method
to get the parameter information forbeanKey
- the key associated with the MBean in the beans map
of the MBeanExporter
MBeanParameterInfo
arrayprotected void populateMBeanDescriptor(Descriptor descriptor, Object managedBean, String beanKey)
Descriptor
for an
MBean. Default implementation sets the currencyTimeLimit
field to
the specified "defaultCurrencyTimeLimit", if any (by default none).
populateMBeanDescriptor
in class AbstractMBeanInfoAssembler
descriptor
- the Descriptor
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 the MBeanExporter
setDefaultCurrencyTimeLimit(Integer)
,
applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey)
Descriptor
for a particular
attribute. 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 the MBeanExporter
setDefaultCurrencyTimeLimit(Integer)
,
applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
protected void populateOperationDescriptor(Descriptor desc, Method method, String beanKey)
Descriptor
for a particular
operation. 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 the MBeanExporter
setDefaultCurrencyTimeLimit(Integer)
,
applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
protected final void applyDefaultCurrencyTimeLimit(Descriptor desc)
currencyTimeLimit
field to the specified
"defaultCurrencyTimeLimit", if any (by default none).
desc
- the JMX attribute or operation descriptorsetDefaultCurrencyTimeLimit(Integer)
protected void applyCurrencyTimeLimit(Descriptor desc, int currencyTimeLimit)
Default implementation sets a value >0
as-is (as number of cache seconds),
turns a value of 0
into Integer.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 applysetDefaultCurrencyTimeLimit(Integer)
,
applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |