Can anyone please clarify what the differences are between the two?
The Javadoc is really obscure for my proper understanding.
One thing I have noticed is if I use ManagementFactory.getPlatformMBeanServer()
to register my MBeans, I can view them in Jconsole. But, not so if I use MBeanServerFactory.createMBeanServer()
.
Why is that? Is that the only diffence?
Thanks.
The ManagementFactory class is a factory class for getting managed beans for the Java platform. This class consists of static methods each of which returns one or more platform MXBeans representing the management interface of a component of the Java virtual machine.
public interface MBeanServer extends MBeanServerConnection. This is the interface for MBean manipulation on the agent side. It contains the methods necessary for the creation, registration, and deletion of MBeans as well as the access methods for registered MBeans. This is the core component of the JMX infrastructure.
Java Management Extensions (JMX) is a Java technology that supplies tools for managing and monitoring applications, system objects, devices (such as printers) and service-oriented networks. Those resources are represented by objects called MBeans (for Managed Bean).
ManagementFactory.getPlatformMBeanServer()
returns a reference to the existing MBean server within the JVM. JConsole looks at the beans on that server.
If you use createMBeanServer()
, that will create an entirely new server. JConsole has no knowledge of it, and so will not see the beans registered with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With