*/
private static void init(final RegistryComponent registryComponent) throws JMXRemoteException {
// Create connector
Map<String, String> environment = new HashMap<String, String>();
JMXServiceURL jmxServiceURL = null;
// Build URL
StringBuilder sb = new StringBuilder(PREFIX_URL_SERVICE);
URI providerURI = null;
if (registryComponent != null) {
try {
providerURI = new URI(registryComponent.getProviderURL());
} catch (URISyntaxException e) {
throw new JMXRemoteException("Cannot get URL from registry component", e);
}
} else {
try {
providerURI = new URI(DEFAULT_RMI);
} catch (URISyntaxException e) {
throw new JMXRemoteException("Cannot get URL from '" + DEFAULT_RMI + "'", e);
}
}
// Switch for the protocol
String protocol = providerURI.getScheme();
String protocolName = "rmi";
if ("iiop".equals(protocol)) {
protocolName = "iiop";
}
sb.append(protocolName);
// Add suffix URL of the service
sb.append(SUFFIX_URL_SERVICE);
// Add rmi URL
sb.append(protocolName);
sb.append("://localhost:");
sb.append(providerURI.getPort());
// Connector
sb.append(SUFFIX_URL);
String url = sb.toString();
try {
jmxServiceURL = new JMXServiceURL(url);
} catch (MalformedURLException e) {
throw new JMXRemoteException("Cannot create jmxservice url with url '" + url + "'.", e);
}
environment.put("jmx.remote.jndi.rebind", "true");
try {