Example usage for com.vaadin.server VaadinSession getUIProviders

List of usage examples for com.vaadin.server VaadinSession getUIProviders

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession getUIProviders.

Prototype

public List<UIProvider> getUIProviders() 

Source Link

Document

Gets the UI providers configured for this session.

Usage

From source file:fr.univlorraine.mondossierweb.utils.MdwSpringVaadinServlet.java

License:Apache License

@Override
protected void servletInitialized() throws ServletException {
    getService().addSessionInitListener(new SessionInitListener() {

        private static final long serialVersionUID = -6307820453486668084L;

        @Override/*from w  w w .  ja  v a 2 s.co m*/
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            WebApplicationContext webApplicationContext = WebApplicationContextUtils
                    .getWebApplicationContext(getServletContext());

            // remove DefaultUIProvider instances to avoid mapping
            // extraneous UIs if e.g. a servlet is declared as a nested
            // class in a UI class
            VaadinSession session = sessionInitEvent.getSession();
            List<UIProvider> uiProviders = new ArrayList<UIProvider>(session.getUIProviders());
            for (UIProvider provider : uiProviders) {
                // use canonical names as these may have been loaded with
                // different classloaders
                if (DefaultUIProvider.class.getCanonicalName().equals(provider.getClass().getCanonicalName())) {
                    session.removeUIProvider(provider);
                }
            }

            // add Spring UI provider
            SpringUIProvider uiProvider = new MdwUIProvider(webApplicationContext);
            session.addUIProvider(uiProvider);
        }
    });
}