Notifications
Clear all

[Solved] How to expose some utility method in JMX console?

3 Posts
2 Users
0 Reactions
1,012 Views
0
Topic starter

Hi,

I want to be able to execute some utility function from JMX console.
I know that I should add some bean into module somewhere but not sure about details.

How to expose some utility method in JMX console?

1 Answer
0
  1. Create an interface named SomethingServiceMBean which has all the methods you want to expose to JMX. The methods should accept only primitives and Strings as inputs, and return String as output. For example, see com.onenetwork.transportation.jmx.TMSSMCServiceMBean
  2. Create an implementation of this interface called SomethingService. It should extend com.transcendsys.platform.base.jmx.AbstractMBean. It is strongly recommended you annotate methods with @Description, @ParamNames and @ParamDescriptions annotations to make them more legible in the JMX console. For example, see com.onenetwork.transportation.jmx.TMSSMCService
  3. In your ModuleContextListener, register your MBean from the moduleInitialized() method. For example:

    MBeanServer mbeanServer = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
    mbeanServer.registerMBean(new TMSSMCService(), new ObjectName(TMSSMCService.NAME));

Alexey Ulyanov Topic starter 2017-06-14 13:06:00

Thanks, Greg. I see controls on JMX UI are taken from method arguments. Does JMX bean UI support only text inputs or we can show some combo with dynamically generated values?

GregMerrill 2017-06-14 15:06:00

To my knowledge, combo fields are not supported and you have to stick with primitives like numbers, Strings and booleans