@Override
public JMXConnector getJMXConnector(JMXServiceDescriptor serviceDescriptor) {
try {
final String transport = serviceDescriptor.getUrl().getProtocol();
final JMXConnectorProvider connectorProvider = getConnectorProvider(transport);
final JMXServiceURL url = getJMXServiceURL(
serviceDescriptor.getUrl().getHost(),
serviceDescriptor.getUrl().getPort(),
serviceDescriptor.getUrl().getProtocol(),
serviceDescriptor.getDomain());
Map<String, Object> environment = null;
if (serviceDescriptor.getUsername() != null) {
environment = new HashMap<String, Object>();
String[] credentials = new String[] {
serviceDescriptor.getUsername(),
serviceDescriptor.getPassword()
};
environment.put(JMXConnector.CREDENTIALS, credentials);
}
return connectorProvider.newJMXConnector(url, environment);
} catch (Exception e) {
KarafWorkbenchActivator.getLogger().error(e.getMessage(), e);
return null;
}
}