Search code examples
javajbossjmxmbeans

Description on JMX fields and methods JBoss


How can we add description on the fields and operations exposed for JMX?

JBoss version : JBoss EAP 5.1.2

We have a Service bean as

@Service
@Management(MyConfigMgnt.class)
public class MyConfigService implements MyConfigLocal, MyConfigMgnt {
     public void setMyValue(String MyValue){}
     public String getMyValue(){}
}

These methods are declared in the MyConfigMgnt interface.

This is visible in the jboss jmx console as enter image description here

and for the field it is shown asenter image description here

How do we add relevant and proper information on the fields and the MBean.

Thanks


Solution

  • There's 2 ways of doing this.

    1. Re-implement your service as a DynamicMBean which is slightly more complicated but allows for the definition of attribute and operation meta-data. (i.e. MyConfigMgnt extends DynamicMBean)
    2. An easier way (but possibly not future-proof) is to use an XMBean descriptor. XMBeans are a proprietary JBoss JMX extension where meta-data is defined in an external XML resource. It would require no actual changes to the source code except the addition of the XMBean resource location which looks something like this:

      @Service(objectName = XMBeanService.OBJECT_NAME, xmbean = "resource:META-INF/service-xmbean.xml")

    If you have a very large number of attributes and operations, the XMBean XML descriptor can be arduous to write, but twiddle has a helper command which will generate a template specific to your existing simple MBean, so you can save the output, fill in the details and go from there.