use of org.eclipse.debug.core.DebugEvent in project bndtools by bndtools.
the class AbstractOSGiLaunchDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
// Register listener to clean up temp files on exit of launched JVM
final ProjectLauncher launcher = getProjectLauncher();
IDebugEventSetListener listener = new IDebugEventSetListener() {
@Override
public void handleDebugEvents(DebugEvent[] events) {
for (DebugEvent event : events) {
if (event.getKind() == DebugEvent.TERMINATE) {
Object source = event.getSource();
if (source instanceof IProcess) {
ILaunch processLaunch = ((IProcess) source).getLaunch();
if (processLaunch == launch) {
// Not interested in any further events =>
// unregister this listener
DebugPlugin.getDefault().removeDebugEventListener(this);
// *may* cause LinkageErrors.
try {
launcher.cleanup();
} catch (Throwable t) {
logger.logError("Error cleaning launcher temporary files", t);
}
LaunchUtils.endRun((Run) launcher.getProject());
}
}
}
}
}
};
DebugPlugin.getDefault().addDebugEventListener(listener);
// Now actually launch
super.launch(configuration, mode, launch, monitor);
}
use of org.eclipse.debug.core.DebugEvent in project bndtools by bndtools.
the class TerminationListener method handleDebugEvents.
public void handleDebugEvents(DebugEvent[] events) {
for (DebugEvent event : events) {
Object source = event.getSource();
if (event.getKind() == DebugEvent.TERMINATE && (source instanceof IProcess) && ((IProcess) source).getLaunch() == launch) {
terminatedProcesses.add((IProcess) source);
boolean isTerminated = true;
IProcess[] createdProcesses = launch.getProcesses();
for (IProcess process : createdProcesses) {
if (!terminatedProcesses.contains(process)) {
isTerminated = false;
break;
}
}
if (isTerminated) {
DebugPlugin.getDefault().removeDebugEventListener(this);
onTerminate.run();
}
}
}
}
Aggregations