Openfire System Properties for JMX
First, you need to add the following to System Properties via the Web Admin Console or add into the table ofproperty.xmpp.jmx.enabled true
xmpp.jmx.port 9111
xmpp.jmx.secure false
Code Snippet
To test it, use the code snippet:String serverUrl = "service:jmx:rmi:///jndi/rmi://localhost:9111/jmxrmi"; JMXServiceURL url = new JMXServiceURL(serverUrl); JMXConnector jmxc = JMXConnectorFactory.connect(url, null); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); ObjectName objectName = new ObjectName("org.eclipse.jetty.webapp:type=webappcontext,id=0,name=ROOT"); Object response = mbsc.getAttribute(objectName, "started"); jmxc.close();
Configure Username and Password for Secure JMX
You could tighten the security by change xmpp.jmx.secure to true. In this case, user name and password must be supplied during connection establishment.String serverUrl = "service:jmx:rmi:///jndi/rmi://localhost:9111/jmxrmi"; JMXServiceURL url = new JMXServiceURL(serverUrl); Map<String, String[]> map = Collections.singletonMap(JMXConnector.CREDENTIALS, new String[]{"admin", "password"}); JMXConnector jmxc = JMXConnectorFactory.connect(url, map); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); ObjectName webAppContext = new ObjectName("org.eclipse.jetty.webapp:type=webappcontext,id=0,name=ROOT"); Object response = mbsc.getAttribute(webAppContext, "started"); jmxc.close();