LifeCycleHandler to hook into the startup process of an e4-app

In the past on RCP 3.x we hooked into the Application*-Classes to popup things like login screens just before the main application came up. With e4 we dont have the Application-Classes anymore, instead there is a standard E4Application-Class wich is responsible to create the Workbench Model and startup the GUI. Using LifeCycleHandlers you we are able to hook into the startup process of an e4 application. You can register a handler from within your plugin.xml by adding a new property named „lifeCycleURI“ like this:

<pre><?xml version="1.0" encoding="UTF-8"?>



So now we have the definition of a LifeCycleHandler and during runtime the class E4Application will look into the plugin „de.hama.ui“ to find a classed named „StartupLifeCycleHandler“ in the package „de.hama.ui.handlers“. Easy stuff so far. Like every handler in e4 a LifeCycleHandler is just a POJO, the difference now is that we do not use the @Execute or @CanExecute-Annotations to define wich method inside the handler has to be executed instead there is a new Eclipse-specific Annotation @PostContextCreate wich we can use to mark the method to be executed.After this method is executed, the e4 main app will show up.

Here is an example of a LifeCycleHandler to open a Login-Dialog right before the startup of the main application:

public class StartupLifeCycleHandler {

LoginDaoJdbc loginDao;

public void startup(IEclipseContext context) {

int i =;
if (i == Window.CANCEL)

context.set("lfsDS", loginDao.getInitialDataSource());
context.set("login", loginDialog.getLogin());


Hope that helps…. have fun!


One Response to LifeCycleHandler to hook into the startup process of an e4-app

  1. Christoph says:

    Thank you very much for this helpful blog entry in reply of my question.

    I have still an unresolved problem. In the StartupLifeCycleHandler i need access to the splash shell otherwise my dialog will disappear behind the splash image if i use the current/active shell.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden /  Ändern )

Google Foto

Du kommentierst mit Deinem Google-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s

%d Bloggern gefällt das: