In a new E4 project I tried to catch UIEvents.UILifeCycle.APP_STARTUP_COMPLETE and UIEvents.UILifeCycle.APP_SHUTDOWN_STARTED lifecycle events but only the startup event is triggered, the shutdown event is not thrown when I quit program with Exit menu or clicking the Windows close button.
In E4LifeCycle.java I tried:
@Inject
@Optional
public void subscribeAppStartupComplete(@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event) {
System.out.println("app startup complete");
}
@Inject
@Optional
public void subscribeAppShutdownStarted(@UIEventTopic(UIEvents.UILifeCycle.APP_SHUTDOWN_STARTED) Event event) {
System.out.println("app shutdown started");
}
Another try with EventHandlers:
@PostContextCreate
void postContextCreate(IEclipseContext workbenchContext) {
eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, startupHandler);
eventBroker.subscribe(UIEvents.UILifeCycle.APP_SHUTDOWN_STARTED, shutdownHandler);
}
private EventHandler startupHandler = new EventHandler() {
@Override
public void handleEvent(org.osgi.service.event.Event event) {
System.out.println("startup handler started");
}
};
private EventHandler shutdownHandler = new EventHandler() {
@Override
public void handleEvent(org.osgi.service.event.Event event) {
System.out.println("shutdown handler started");
}
};
Is there a better method to catch this event ?
(Eclipse Neon M4 but it is also reproducible in Eclipse Mars)