Search in sources :

Example 1 with PushConfiguration

use of com.vaadin.flow.component.PushConfiguration in project flow by vaadin.

the class BootstrapHandler method createAndInitUI.

protected BootstrapContext createAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session) {
    UI ui = ReflectTools.createInstance(uiClass);
    PushConfiguration pushConfiguration = ui.getPushConfiguration();
    ui.getInternals().setSession(session);
    ui.setLocale(session.getLocale());
    BootstrapContext context = new BootstrapContext(request, response, session, ui);
    Optional<Push> push = context.getPageConfigurationAnnotation(Push.class);
    DeploymentConfiguration deploymentConfiguration = context.getSession().getService().getDeploymentConfiguration();
    PushMode pushMode = push.map(Push::value).orElseGet(deploymentConfiguration::getPushMode);
    pushConfiguration.setPushMode(pushMode);
    pushConfiguration.setPushUrl(deploymentConfiguration.getPushURL());
    push.map(Push::transport).ifPresent(pushConfiguration::setTransport);
    // Set thread local here so it is available in init
    UI.setCurrent(ui);
    ui.doInit(request, session.getNextUIid());
    session.addUI(ui);
    // After init and adding UI to session fire init listeners.
    session.getService().fireUIInitListeners(ui);
    return context;
}
Also used : PushConfiguration(com.vaadin.flow.component.PushConfiguration) UI(com.vaadin.flow.component.UI) Push(com.vaadin.flow.component.page.Push) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) PushMode(com.vaadin.flow.shared.communication.PushMode)

Aggregations

PushConfiguration (com.vaadin.flow.component.PushConfiguration)1 UI (com.vaadin.flow.component.UI)1 Push (com.vaadin.flow.component.page.Push)1 DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)1 PushMode (com.vaadin.flow.shared.communication.PushMode)1