use of com.sun.tools.jconsole.JConsoleContext in project wildfly-core by wildfly.
the class JConsoleCLIPlugin method connect.
private void connect() throws Exception {
JConsoleContext jcCtx = this.getContext();
MBeanServerConnection mbeanServerConn = jcCtx.getMBeanServerConnection();
if (mbeanServerConn instanceof RemotingMBeanServerConnection) {
final CommandContext cmdCtx = CommandContextFactory.getInstance().newCommandContext();
if (connectUsingRemoting(cmdCtx, (RemotingMBeanServerConnection) mbeanServerConn)) {
// Set a listener for connection state change.
jcCtx.addPropertyChangeListener((PropertyChangeEvent evt) -> {
log.tracef("Received property change %s value %s", evt.getPropertyName(), evt.getNewValue());
if (JConsoleContext.CONNECTION_STATE_PROPERTY.equals(evt.getPropertyName())) {
ConnectionState state = (ConnectionState) evt.getNewValue();
if (state == ConnectionState.CONNECTED) {
try {
// Rebuild the ModelControllerClient
RemotingMBeanServerConnection rmbsc = (RemotingMBeanServerConnection) getContext().getMBeanServerConnection();
connectUsingRemoting(cmdCtx, rmbsc);
connectedClient = cmdCtx.getModelControllerClient();
isConnected = true;
} catch (Exception ex) {
log.error(null, ex);
}
} else {
isConnected = false;
}
}
});
connectedClient = cmdCtx.getModelControllerClient();
Supplier<ModelControllerClient> client = () -> {
return connectedClient;
};
init(cmdCtx, client);
} else {
JOptionPane.showInternalMessageDialog(jconsolePanel, MSG_CANNOT_ESTABLISH_CONNECTION);
}
} else {
// show dialog
dialog.start();
}
}
use of com.sun.tools.jconsole.JConsoleContext in project visualgc_java8 by beansoft.
the class PluginAdapter method getTabs.
@Override
public Map<String, JPanel> getTabs() {
topthreadsPanel = new TopThreadsPanel();
addContextPropertyChangeListener(new ConnectionListener());
// See if we've got a connection right now
JConsoleContext ctx = getContext();
if (ctx != null && JConsoleContext.ConnectionState.CONNECTED.equals(ctx.getConnectionState())) {
MBeanServerConnection connection = getContext().getMBeanServerConnection();
if (connection != null)
topthreadsPanel.connect(connection);
}
return Collections.singletonMap(TAB_NAME, (JPanel) topthreadsPanel);
}
Aggregations