final MBeanServerConnectionJob mbeanConnectionJob;
try {
final JMXServiceURL standardJmxConnection = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:" + jmxPort + "/jmxrmi"); //$NON-NLS-1$ $NON-NLS-2$
final JMXServiceDescriptor descriptor = new LocalJMXServiceDescriptor(
configuration.getName(),
platformModel,
standardJmxConnection,
null,
null,
JMX_JMXRMI_DOMAIN);
mbeanConnectionJob = new MBeanServerConnectionJob(configuration.getName(), descriptor);
mbeanProviderDataMap.get(memento).setMbeanConnectionJob(mbeanConnectionJob);
mbeanProviderDataMap.get(memento).setJmxServiceDescriptor(descriptor);
jmxServiceManager.add(descriptor);
} catch(final MalformedURLException e) {
KarafWorkbenchActivator.getLogger().error("Unable to connect to JMX endpoint on Karaf instance", e);
throw new CoreException(new Status(IStatus.ERROR, "", "")); //$NON-NLS-1$ $NON-NLS-2$
}
final IJobChangeListener listener = new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
final IStatus result = event.getResult();
if (result == null || !result.isOK()) {
// TODO: Log something
return;
}
if (!mbeanConnectionJob.isConnected()) {
// TODO: Log something
return;
}
final KarafMBeanProvider mbeanProvider;
try {
final JMXServiceDescriptor jmxServiceDescriptor = mbeanProviderDataMap.get(memento).getJmxServiceDescriptor();
mbeanProvider = new LocalKarafMBeanProvider(jmxServiceDescriptor, mbeanConnectionJob.getJmxClient(), platformModel);
mbeanProvider.open(memento);
mbeanProviderDataMap.get(memento).setMbeanProvider(mbeanProvider);
mbeanProviderManager.add(mbeanProvider);