~~NOTRANS~~
~~Title: Access Launcher and Application Before Application Starts~~
Sometimes, it's important to configure the application or to set custom properties into the launcher before the application starts. This could be useful if external authentication systems will be used, e.g., via SpringSecurity or different authentication filters.
It's still possible to use special authenticators for your application, but sometimes this mechanism is too late because the http filter handles authentication.
Usually, you would extend the standard VaadinUI implementation to do some tweaks, but not everything is possible because you can't do anything between launcher creation and application instantiation.
If you need early access to launcher and application, you could use the IVaadinUIPhaseController. It's a simple interface that defines a phaseChanged method. This method will be called at specific states of VaadinUI.
You can use it to get access to the launcher directly after its creation or to access the application instance before it will be visible.
Simply add an init-parameter to your web.xml:
phaseController
com.sibvisions.apps.vaadin.CustomUIPhaseController
//(if you run a portlet, use the parameter name: vaadinui.phaseController)//
The parameter defines your implementation of IVaadinUIPhaseController, e.g.,
public class CustomUIPhaseController implements IVaadinUIPhaseController
{
public void phaseChanged(UIPhaseEvent pEvent)
{
switch (pEvent.getPhase())
{
case UIPhaseEvent.PHASE_CONFIGURE_LAUNCHER:
System.out.println("Configure Launcher via UI phase controller");
System.out.println(((LauncherEvent)pEvent).getLauncher().
getParameter(VaadinUI.PARAM_REQUESTURL));
break;
default:
//not handled
break;
}
}
}
The UIPhaseEvent defines the phases: //PHASE_CONFIGURE_LAUNCHER//, //PHASE_CONFIGURE_APPLICATION//, //PHASE_BEFORE_NOTIFYVISIBLE//.
The PHASE_CONFIGURE_LAUNCHER phase will be fired, directly after launcher creation and before application instantiation. The PHASE_CONFIGURE_APPLICATION will be fired after the application instance was created. The PHASE_BEFORE_NOTIFYVISIBLE will be fired before the notifyVisible method of the application will be invoked.