Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Extension point for terminating process
Extension point for terminating process [message #252868] Mon, 21 April 2008 08:42 Go to next message
Eclipse UserFriend
Originally posted by: amcraft.emailplus.org

I am trying to create a plug-in to customise the termination of launched
process (java in the first example).

The problem I'm trying to solve is when developing on windows terminating
a process, abruptly terminates it and no shutdown hooks run. What I want
to do is have the option to provide some termination script, which might
invoke some custom shutdown method before resorting to the default
termination process.

I have registered an extension "org.eclipse.debug.core.launchDelegates" to
allow an extra tab in the run profile dialog. What I need to do next is
intercept the terminate request and try to run this script if specified
and if it fails fall back to the default. Can someone advise how I can
achieve this. Is there a way of listening for termination of process or i
need to create some kind of custom launcher?

thanks
Re: Extension point for terminating process [message #252872 is a reply to message #252868] Mon, 21 April 2008 08:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amcraft.emailplus.org

meant "org.eclipse.debug.ui.launchConfigurationTabs" for adding config to
the run dialog!
Re: Extension point for terminating process [message #252905 is a reply to message #252872] Tue, 22 April 2008 07:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amcraft.emailplus.org

I have extended JavaLaunchDelegate and registered as a launch delegate. I
then override the getLaunch method, my idea is to wrap the object returned
by calling super.getLaunch in my own object so i can override the
terminate method, but when i call the super.getLaunch() it returns null?
How do i generate the default launch object.

(I tried creating ILaunch launch = new Launch(configuration,mode, null);
but then the process I launch never runs?)
Re: Extension point for terminating process [message #1628056 is a reply to message #252905] Sat, 21 February 2015 18:07 Go to previous message
Eclipse UserFriend
As I wrote here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016
I solve that problem by adding a decorator to IProcess after launch:

In launch of MyLaunchDelegate extends JavaLaunchDelegate I add decorator just after process is launched:
		super.launch(configuration, mode, launch, monitor);
		
		if(!debug) {
			IProcess p = launch.getProcesses()[0];
			launch.addProcess(new ProcessDecorator(p));
			launch.removeProcess(p);
		}

In this decorator I am doing:
public class ProcessDecorator implements IProcess {

	private IProcess p;
	
	public ProcessDecorator(IProcess p) {
		this.p = p;
	}

	@SuppressWarnings("rawtypes")
	@Override public Object        getAdapter(Class arg)                { return p.getAdapter(arg); }
	@Override public boolean       canTerminate()                       { return p.canTerminate(); }
	@Override public boolean       isTerminated()                       { return p.isTerminated(); }
	@Override public String        getAttribute(String s)               { return p.getAttribute(s); }
	@Override public int           getExitValue() throws DebugException { return p.getExitValue(); }
	@Override public String        getLabel()                           { return p.getLabel(); }
	@Override public ILaunch       getLaunch()                          { return p.getLaunch(); }
	@Override public IStreamsProxy getStreamsProxy()                    { return p.getStreamsProxy(); }
	@Override public void          setAttribute(String s1, String s2)   {        p.setAttribute(s1, s2); }
	@Override public void          terminate() throws DebugException    {
                // TODO: custom termination

		p.terminate();
	}
}
Previous Topic:Delete default package
Next Topic:Eclipse Luna doesn't work properly with jdk8 in OS X Yosemite
Goto Forum:
  


Current Time: Sat May 10 01:00:56 EDT 2025

Powered by FUDForum. Page generated in 0.03277 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top