Reputation: 36634
For a simple Java library which performs operations in constant intervals I have implemented JMX management using MXBeans and it works as expected, I can query the status and set parameters, supend / resume the operations etc in JConsole.
Now I would like to create a web application - to display and control the library operation.
I don't know wether it is a good idea to use the samy JMX API also in the web application, so I need a way to access the MXBeans which are registered in the same VM using the platform MBean Server:
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
I noticed that the MBeanServer has a queryMBeans method. Should I use this method to access the registered JMX API MXBeans? There is a different path, using JMXConnectorFactory, which requires protocol, host, and port information so that the client can access a remote JMX server.
Upvotes: 11
Views: 7253
Reputation: 403441
If you only want to access the MBeanServer in the same JVM, then ManagementFactory.getPlatformMBeanServer();
is the way to do it.
JMXConnectorFactory
is for accessing remote MBeanServers (i.e. in a different JVM, and/or on a different host).
Upvotes: 16