use of javax.management.remote.jmxmp.JMXMPConnectorServer in project Payara by payara.
the class JMXMPConnectorStarter method startJMXMPConnectorServer.
private JMXConnectorServer startJMXMPConnectorServer(final int port) throws MalformedURLException, IOException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
final Map<String, Object> env = new HashMap<String, Object>();
env.put("jmx.remote.protocol.provider.pkgs", "com.sun.jmx.remote.protocol");
env.put("jmx.remote.protocol.provider.class.loader", this.getClass().getClassLoader());
env.put("jmx.remote.rmi.server.credential.types", new String[] { String[].class.getName(), String.class.getName() });
JMXAuthenticator authenticator = getAccessController();
if (authenticator != null) {
env.put("jmx.remote.authenticator", authenticator);
}
final JMXServiceURL serviceURL = new JMXServiceURL("service:jmx:" + JMXMP + "://" + hostname() + ":" + port);
JMXConnectorServer jmxmp = null;
boolean startedOK = false;
try {
jmxmp = new JMXMPConnectorServer(serviceURL, env, mMBeanServer);
if (mBootListener != null) {
jmxmp.addNotificationListener(mBootListener, null, serviceURL.toString());
}
jmxmp.start();
startedOK = true;
} catch (final Exception e) {
e.printStackTrace();
} finally {
// we do it this way so that the original exeption will be thrown out
if (!startedOK) {
try {
if (jmxmp != null) {
jmxmp.stop();
}
} catch (Exception e) {
ignore(e);
}
}
}
mJMXServiceURL = serviceURL;
mConnectorServer = jmxmp;
return mConnectorServer;
}
Aggregations