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;
}
Aggregations