Skip to content

Commit

Permalink
JBIDE-24593 - be a bit more helpful with jmx progress
Browse files Browse the repository at this point in the history
  • Loading branch information
robstryker committed Jun 28, 2017
1 parent 38e2254 commit f85e515
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
Expand Up @@ -13,7 +13,10 @@
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;

import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.jboss.tools.jmx.core.IAsyncRefreshable;
import org.jboss.tools.jmx.core.IConnectionWrapper;
Expand Down Expand Up @@ -44,46 +47,50 @@ public ObjectNameNode(Node parent, String key, String value, ObjectName on, MBea
}

private synchronized void loadInfo(MBeanServerConnection mbsc) {
loadInfo(mbsc, new NullProgressMonitor());
}

private synchronized void loadInfo(MBeanServerConnection mbsc, IProgressMonitor mon) {
mon.beginTask("Loading Object Name Node " + on.getCanonicalName(), 100);
mon.worked(5);
Root root = getRoot(parent);
IConnectionWrapper connectionWrapper = root.getConnection();
final MBeanInfoWrapper[] array = new MBeanInfoWrapper[1];
final ObjectName on2 = on;
try {
if( mbsc != null ) {
MBeanInfo mbi = null;
try {
mbi = mbsc.getMBeanInfo(on2);
} catch(IOException ioe) {
// Ignore
}
if( mbi != null ) {
array[0] = new MBeanInfoWrapper(on2, mbi, mbsc, ObjectNameNode.this);
}
array[0] = loadInfoInternal(mbsc);
} else {
connectionWrapper.run(new IJMXRunnable() {
@Override
public void run(MBeanServerConnection mbsc) throws Exception {
MBeanInfo mbi = null;
try {
mbi = mbsc.getMBeanInfo(on2);
} catch(IOException ioe) {
// Ignore
}

if( mbi != null ) {
array[0] = new MBeanInfoWrapper(on2, mbi, mbsc, ObjectNameNode.this);
}
array[0] = loadInfoInternal(mbsc);
}
});
}
mon.worked(95);
} catch( Exception e ) {
JMXActivator.getDefault().getLog().log(new Status(IStatus.ERROR, JMXActivator.PLUGIN_ID,
"Error loading object name details for JMX object: " + on.toString(), e));
loadError = e;
}
mon.done();
wrapper = array[0];
}

private synchronized MBeanInfoWrapper loadInfoInternal(MBeanServerConnection mbsc) throws Exception {
final ObjectName on2 = on;
MBeanInfo mbi = null;
try {
mbi = mbsc.getMBeanInfo(on2);
} catch(IOException ioe) {
// Ignore
}
if( mbi != null ) {
return new MBeanInfoWrapper(on2, mbi, mbsc, ObjectNameNode.this);
}
return null;
}

public boolean hasLoadError() {
return loadError != null;
}
Expand All @@ -93,8 +100,11 @@ public ObjectName getObjectName() {
}

public synchronized MBeanInfoWrapper getMbeanInfoWrapper() {
return getMbeanInfoWrapper(null);
}
public synchronized MBeanInfoWrapper getMbeanInfoWrapper(IProgressMonitor mon) {
if( wrapper == null ) {
loadInfo(null);
loadInfo(null, mon);
}
return wrapper;
}
Expand Down
Expand Up @@ -260,7 +260,7 @@ protected synchronized Object[] loadAndGetMbeanInfoWrapper(final ObjectNameNode
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
parent.getMbeanInfoWrapper();
parent.getMbeanInfoWrapper(monitor);
} finally {
loadingObjectNameNode.remove(parent);
}
Expand Down

0 comments on commit f85e515

Please sign in to comment.