public abstract class AbstractMBeanInfoAssembler extends Object implements MBeanInfoAssembler
MBeanInfoAssembler
interface
that encapsulates the creation of a ModelMBeanInfo
instance
but delegates the creation of metadata to subclasses.
This class offers two flavors of Class extraction from a managed bean
instance: getTargetClass(java.lang.Object)
, extracting the target class behind
any kind of AOP proxy, and getClassToExpose(java.lang.Object)
, returning the
class or interface that will be searched for annotations and exposed
to the JMX runtime.
Constructor and Description |
---|
AbstractMBeanInfoAssembler() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkManagedBean(Object managedBean)
Check the given bean instance, throwing an IllegalArgumentException
if it is not eligible for exposure with this assembler.
|
protected abstract ModelMBeanAttributeInfo[] |
getAttributeInfo(Object managedBean,
String beanKey)
Get the attribute metadata for the MBean resource.
|
protected String |
getClassName(Object managedBean,
String beanKey)
Get the class name of the MBean resource.
|
protected Class<?> |
getClassToExpose(Class<?> beanClass)
Return the class or interface to expose for the given bean class.
|
protected Class<?> |
getClassToExpose(Object managedBean)
Return the class or interface to expose for the given bean.
|
protected ModelMBeanConstructorInfo[] |
getConstructorInfo(Object managedBean,
String beanKey)
Get the constructor metadata for the MBean resource.
|
protected String |
getDescription(Object managedBean,
String beanKey)
Get the description of the MBean resource.
|
ModelMBeanInfo |
getMBeanInfo(Object managedBean,
String beanKey)
Create an instance of the
ModelMBeanInfoSupport class supplied with all
JMX implementations and populates the metadata through calls to the subclass. |
protected ModelMBeanNotificationInfo[] |
getNotificationInfo(Object managedBean,
String beanKey)
Get the notification metadata for the MBean resource.
|
protected abstract ModelMBeanOperationInfo[] |
getOperationInfo(Object managedBean,
String beanKey)
Get the operation metadata for the MBean resource.
|
protected Class<?> |
getTargetClass(Object managedBean)
Return the actual bean class of the given bean instance.
|
protected void |
populateMBeanDescriptor(Descriptor descriptor,
Object managedBean,
String beanKey)
Called after the
ModelMBeanInfo instance has been constructed but
before it is passed to the MBeanExporter . |
public ModelMBeanInfo getMBeanInfo(Object managedBean, String beanKey) throws JMException
ModelMBeanInfoSupport
class supplied with all
JMX implementations and populates the metadata through calls to the subclass.getMBeanInfo
in interface MBeanInfoAssembler
managedBean
- the bean that will be exposed (might be an AOP proxy)beanKey
- the key associated with the managed beanJMException
- in case of errorsgetDescription(Object, String)
,
getAttributeInfo(Object, String)
,
getConstructorInfo(Object, String)
,
getOperationInfo(Object, String)
,
getNotificationInfo(Object, String)
,
populateMBeanDescriptor(javax.management.Descriptor, Object, String)
protected void checkManagedBean(Object managedBean) throws IllegalArgumentException
Default implementation is empty, accepting every bean instance.
managedBean
- the bean that will be exposed (might be an AOP proxy)IllegalArgumentException
- the bean is not valid for exposureprotected Class<?> getTargetClass(Object managedBean)
Default implementation returns the target class for an AOP proxy, and the plain bean class else.
managedBean
- the bean instance (might be an AOP proxy)AopUtils.getTargetClass(Object)
protected Class<?> getClassToExpose(Object managedBean)
managedBean
- the bean instance (might be an AOP proxy)JmxUtils.getClassToExpose(Object)
protected Class<?> getClassToExpose(Class<?> beanClass)
beanClass
- the bean class (might be an AOP proxy class)JmxUtils.getClassToExpose(Class)
protected String getClassName(Object managedBean, String beanKey) throws JMException
Default implementation returns a simple description for the MBean based on the class name.
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 errorsprotected String getDescription(Object managedBean, String beanKey) throws JMException
Default implementation returns a simple description for the MBean based on the class name.
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 errorsprotected void populateMBeanDescriptor(Descriptor descriptor, Object managedBean, String beanKey) throws JMException
ModelMBeanInfo
instance has been constructed but
before it is passed to the MBeanExporter
.
Subclasses can implement this method to add additional descriptors to the MBean metadata. Default implementation is empty.
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
JMException
- in case of errorsprotected ModelMBeanConstructorInfo[] getConstructorInfo(Object managedBean, String beanKey) throws JMException
Default implementation returns an empty array of ModelMBeanConstructorInfo
.
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 errorsprotected ModelMBeanNotificationInfo[] getNotificationInfo(Object managedBean, String beanKey) throws JMException
Default implementation returns an empty array of ModelMBeanNotificationInfo
.
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 errorsprotected abstract ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException
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 errorsprotected abstract ModelMBeanOperationInfo[] getOperationInfo(Object managedBean, String beanKey) throws JMException
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 errors