Bug 445451 - Result value is not picked up if app shuts down because @PostContextCreate returns false
Summary: Result value is not picked up if app shuts down because @PostContextCreate re...
Status: CLOSED DUPLICATE of bug 421153
Alias: None
Product: Efxclipse
Classification: Technology
Component: Runtime (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-30 03:55 EDT by Christoph Keimel CLA
Modified: 2014-10-13 08:15 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Keimel CLA 2014-09-30 03:55:49 EDT
It is possible to stop the start of the application by returning false in @PostContextCreate. It is also possible to use the key e4.osgi.exit.code in the application context to set a return value if the application gets shut down normaly.

Combining these features, you would expect the following to restart the application.

@PostContextCreate
Boolean postContextCreate(IEclipseContext context) {
	context.set(Constants.EXIT_CODE, IApplication.EXIT_RESTART);
	return false;
}

To solve the issue I would like to:
- change E4Application so the return value is also calculated after @PostContextCreate retuns false
- make the constant EXIT_CODE public API

In addition to this, I would also like to make the RestartPreferenceUtil public, so that it is possible to use it like this:

@PostContextCreate
Boolean postContextCreate(IEclipseContext context, RestartPreferenceUtil restartPref) {
	restartPref.setClearPersistedStateOnRestart(true);
	context.set(Constants.EXIT_CODE, IApplication.EXIT_RESTART);
	return false;
}

This is similar to Bug 421153, as it adresses the same need, but has a different approach to the solution.
Comment 1 Christoph Keimel CLA 2014-09-30 03:59:54 EDT
implementation proposal:
https://git.eclipse.org/r/34096
Comment 2 Christoph Keimel CLA 2014-09-30 04:58:28 EDT
I like the solution proposed in Bug 421153 better than this. 

Tom: If you agree I would mark this bug as a duplicate and abandon the changeset.
Comment 3 Christoph Keimel CLA 2014-10-13 08:15:59 EDT

*** This bug has been marked as a duplicate of bug 421153 ***