Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ManagementFactory.getPlatformMBeanServer() vs MBeanServerFactory.createMBeanServer()

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.

like image 338
His Avatar asked Oct 13 '10 14:10

His


People also ask

What is ManagementFactory?

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.

What is MBeanServer Java?

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.

What are JMX beans?

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).


1 Answers

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.

like image 99
skaffman Avatar answered Sep 30 '22 08:09

skaffman