List of usage examples for com.vaadin.server DefaultUIProvider DefaultUIProvider
DefaultUIProvider
From source file:org.rapidpm.ddi.DDIVaadinServletService.java
License:Apache License
public DDIVaadinServletService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration) throws ServiceException { super(servlet, deploymentConfiguration); if (DI.isPkgPrefixActivated(PKG_PREFIX)) { //nothing.... System.out.println(//from w w w. j a va 2 s .c om "DI.getPkgPrefixActivatedTimestamp() = " + DI.getPkgPrefixActivatedTimestamp(PKG_PREFIX)); } else { // final VaadinServlet current = VaadinServlet.getCurrent(); // final ServletContext currentServletContext = current.getServletContext(); System.out.println( "DDIVaadinServletService-DI.activatePackages-LocalDateTime.now() = " + LocalDateTime.now()); final ServletContext currentServletContext = servlet.getServletContext(); final Collection<URL> urlsWebInfLib = ClasspathHelper.forWebInfLib(currentServletContext); final List<URL> urlList = urlsWebInfLib.stream().filter(u -> u.toString().contains("rapidpm-")) //reduce the jars to scann .collect(Collectors.toList()); DI.activatePackages(PKG_PREFIX, urlList); //reduce the classes to scann System.out.println( "DDIVaadinServletService-DI.activatePackages-LocalDateTime.now() = " + LocalDateTime.now()); //inject } addSessionInitListener(event -> event.getSession().addUIProvider(new DefaultUIProvider() { @Override public UI createInstance(final UICreateEvent event) { final UI instance = super.createInstance(event); //metrics - System.out.println("DDIVaadinServletService.getInstance-instance = " + instance); return DI.activateDI(instance); } })); addSessionDestroyListener(event -> { System.out.println("addSessionDestroyListener-event = " + event); // VaadinSessionDestroyEvent sessionDestroyEvent = new VaadinSessionDestroyEvent(CDIUtil.getSessionId(event.getSession())); // getBeanManager().fireEvent(sessionDestroyEvent); }); }