tags:

views:

47

answers:

1

How to create performance counters that are exposed by jmx and accessed via jconsole?

Say whenever I instantiate a particular object, I increment a counter. I want to expose the counter value so I can view the value in jconsole.

How would I go about doing this?

+1  A: 

There's a few steps:

  • Define an MBean interface that exposes your counter.
  • Create an implementation of that interface
  • Register the implementation with the platform MBean server using ManagementFactory.getPlatformMBeanServer().registerMBean(...)
  • Access the MBean from jconsole

There are details in the JMX tutorial.

Dave Ray