credentials,
noAvailableInputStream,
outputStream,
outputStream);
final KarafRemoteShellConnectJob job = new KarafRemoteShellConnectJob(name, shellConnection);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
if (!event.getResult().isOK()) {
final Throwable t = event.getResult().getException();
writeTo(outputStream, "Unable to connect to SSH server: " + (t != null ? t.getLocalizedMessage() : "Unknown error"));
}
}
});
DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
@Override
public void handleDebugEvents(final DebugEvent[] events) {
for (final DebugEvent event : events) {
if ( process != null
&& process.equals(event.getSource())
&& event.getKind() == DebugEvent.TERMINATE)
{
job.cancel();
}
}
}
});
job.schedule(15 * 1000);
} else {
writeTo(outputStream, "The Karaf remote shell is disabled. Enable it in the launch configuration dialog.");
}
}