Map<String, Object> env = new HashMap<String, Object>();
if (jmxUsername != null && jmxPassword != null) {
String[] credentials = new String[] { jmxUsername, jmxPassword };
env.put(JMXConnector.CREDENTIALS, credentials);
}
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env);
mbeanServer = connector.getMBeanServerConnection();
} catch (Exception ex) {
LOGGER.warn("Cannot create JMXServiceURL from: {}", jmxServiceURL);
}
return mbeanServer;
}