Example usage for com.vaadin.server SessionInitEvent getSession

List of usage examples for com.vaadin.server SessionInitEvent getSession

Introduction

In this page you can find the example usage for com.vaadin.server SessionInitEvent getSession.

Prototype

public VaadinSession getSession() 

Source Link

Document

Gets the Vaadin service session that has been initialized.

Usage

From source file:org.vaadin.spring.internal.SpringAwareVaadinServlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    getService().addSessionInitListener(new SessionInitListener() {
        @Override//from  w w  w.ja v a2s  .com
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            WebApplicationContext webApplicationContext = WebApplicationContextUtils
                    .getWebApplicationContext(getServletContext());
            UIScopeAwareUIProvider uiProvider = new UIScopeAwareUIProvider(webApplicationContext);
            sessionInitEvent.getSession().addUIProvider(uiProvider);
        }
    });
}

From source file:org.vaadin.spring.servlet.SpringAwareVaadinServlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    getService().addSessionInitListener(new SessionInitListener() {
        @Override/*from   w w w  .  ja va2 s .  c  o  m*/
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            WebApplicationContext webApplicationContext = WebApplicationContextUtils
                    .getWebApplicationContext(getServletContext());
            SpringAwareUIProvider uiProvider = new SpringAwareUIProvider(webApplicationContext);
            sessionInitEvent.getSession().addUIProvider(uiProvider);
        }
    });
}

From source file:org.vaadin.spring.touchkit.servlet.SpringAwareTouchKitServlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    super.servletInitialized();
    getService().addSessionInitListener(new SessionInitListener() {
        @Override/*w ww. j  av a 2  s.c  o m*/
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            WebApplicationContext webApplicationContext = WebApplicationContextUtils
                    .getWebApplicationContext(getServletContext());
            SpringAwareTouchKitUIProvider uiProvider = new SpringAwareTouchKitUIProvider(webApplicationContext);
            sessionInitEvent.getSession().addUIProvider(uiProvider);
        }
    });
}

From source file:org.vaadin.webinars.springandvaadin.i18n.ui.createTask.CreateTaskServlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    final ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    getService().addSessionInitListener(new SessionInitListener() {
        @Override//from  w  ww. j av  a2s.  c om
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            sessionInitEvent.getSession().addUIProvider(new UIProvider() {
                @Override
                public Class<? extends UI> getUIClass(UIClassSelectionEvent uiClassSelectionEvent) {
                    return CreateTaskUi.class;
                }

                @Override
                public UI createInstance(UICreateEvent event) {
                    return context.getBean(event.getUIClass());
                }
            });
        }
    });
}

From source file:org.vaadin.webinars.springandvaadin.i18n.ui.Servlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    final ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    try {/*from   w w w . ja va  2s.  co m*/
        localeResolver = context.getBean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, LocaleResolver.class);
    } catch (NoSuchBeanDefinitionException e) {
        localeResolver = new SessionLocaleResolver();
    }
    getService().addSessionInitListener(new SessionInitListener() {
        @Override
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            sessionInitEvent.getSession().addUIProvider(new UIProvider() {
                @Override
                public Class<? extends UI> getUIClass(UIClassSelectionEvent uiClassSelectionEvent) {
                    return I18nUI.class;
                }

                @Override
                public UI createInstance(UICreateEvent event) {
                    return context.getBean(event.getUIClass());
                }
            });
        }
    });
}

From source file:pl.exsio.frameset.vaadin.bootstrap.servlet.FramesetServlet.java

License:Open Source License

protected void initializeApplication(VaadinServletService service) {
    if (this.systemMessagesBeanName != null && !"".equals(this.systemMessagesBeanName)) {
        FramesetSystemMessagesProvider messagesProvider = new FramesetSystemMessagesProvider(
                this.applicationContext, this.systemMessagesBeanName);
        service.setSystemMessagesProvider(messagesProvider);
    }//w w w  . j av a  2 s.co m

    String uiProviderProperty = service.getDeploymentConfiguration()
            .getApplicationOrSystemProperty(Constants.SERVLET_PARAMETER_UI_PROVIDER, null);

    if (uiProviderProperty == null) {
        service.addSessionInitListener(new SessionInitListener() {
            @Override
            public void sessionInit(SessionInitEvent event) throws ServiceException {
                event.getSession().addUIProvider(new FramesetUIProvider());
            }
        });
    }
}