Example usage for com.vaadin.server VaadinSession removeUIProvider

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

Introduction

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

Prototype

public void removeUIProvider(UIProvider uiProvider) 

Source Link

Document

Removes a UI provider association from 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 ww w  .ja v a2  s  .c om*/
        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);
        }
    });
}