VaadinService implements Serializable { public void init() throws ServiceException { instantiator = createInstantiator(); router = new Router(getRouteRegistry()); List<RequestHandler> handlers = createRequestHandlers(); ServiceInitEvent event = new ServiceInitEvent(this); runWithServiceContext(() -> { instantiator.getServiceInitListeners() .forEach(listener -> listener.serviceInit(event)); event.getAddedRequestHandlers().forEach(handlers::add); Collections.reverse(handlers); requestHandlers = Collections.unmodifiableCollection(handlers); dependencyFilters = instantiator .getDependencyFilters(event.getAddedDependencyFilters()) .collect(Collectors.toList()); bootstrapListeners = instantiator .getBootstrapListeners(event.getAddedBootstrapListeners()) .collect(Collectors.toList()); indexHtmlRequestListeners = instantiator .getIndexHtmlRequestListeners( event.getAddedIndexHtmlRequestListeners()) .collect(Collectors.toList()); }); DeploymentConfiguration configuration = getDeploymentConfiguration(); if (!configuration.isProductionMode()) { Logger logger = getLogger(); logger.debug("The application has the following routes: "); List<RouteData> routeDataList = getRouteRegistry().getRegisteredRoutes(); if(!routeDataList.isEmpty()) { addRouterUsageStatistics(); } routeDataList.stream() .map(Object::toString).forEach(logger::debug); } if (getDeploymentConfiguration().isPnpmEnabled()) { UsageStatistics.markAsUsed("flow/pnpm",null); } initialized = true; } VaadinService(DeploymentConfiguration deploymentConfiguration); protected  VaadinService(); void init(); abstract String getContextRootRelativePath(VaadinRequest request); Instantiator getInstantiator(); ClassLoader getClassLoader(); void setClassLoader(ClassLoader classLoader); abstract String getMimeType(String resourceName); DeploymentConfiguration getDeploymentConfiguration(); void setSystemMessagesProvider(
            SystemMessagesProvider systemMessagesProvider); SystemMessagesProvider getSystemMessagesProvider(); SystemMessages getSystemMessages(Locale locale,
            VaadinRequest request); Registration addSessionInitListener(SessionInitListener listener); Registration addUIInitListener(UIInitListener listener); Registration addSessionDestroyListener(
            SessionDestroyListener listener); @Deprecated void modifyBootstrapPage(BootstrapPageResponse response); void modifyIndexHtmlResponse(IndexHtmlResponse response); void fireSessionDestroy(VaadinSession vaadinSession); VaadinSession findVaadinSession(VaadinRequest request); static VaadinService getCurrent(); void setCurrentInstances(VaadinRequest request,
            VaadinResponse response); static void setCurrent(VaadinService service); static VaadinRequest getCurrentRequest(); static VaadinResponse getCurrentResponse(); abstract String getServiceName(); UI findUI(VaadinRequest request); static void reinitializeSession(VaadinRequest request); abstract String getMainDivId(VaadinSession session,
            VaadinRequest request); void closeSession(VaadinSession session); boolean isUIActive(UI ui); void requestStart(VaadinRequest request, VaadinResponse response); void requestEnd(VaadinRequest request, VaadinResponse response,
            VaadinSession session); Iterable<RequestHandler> getRequestHandlers(); Iterable<DependencyFilter> getDependencyFilters(); void handleRequest(VaadinRequest request, VaadinResponse response); void writeStringResponse(VaadinResponse response, String contentType,
            String responseString); void writeUncachedStringResponse(VaadinResponse response,
            String contentType, String responseString); static String createCriticalNotificationJSON(String caption,
            String message, String details, String url); static String createCriticalNotificationJSON(String caption,
            String message, String details, String url, String querySelector); static String createSessionExpiredJSON(boolean async); static String createUINotFoundJSON(boolean async); boolean ensurePushAvailable(); static void verifyNoOtherSessionLocked(VaadinSession session); static boolean isOtherSessionLocked(VaadinSession session); static boolean isCsrfTokenValid(UI ui, String requestToken); Future<Void> accessSession(VaadinSession session, Command command); void ensureAccessQueuePurged(VaadinSession session); void runPendingAccessTasks(VaadinSession session); Registration addServiceDestroyListener(
            ServiceDestroyListener listener); void destroy(); void removeSession(WrappedSession wrappedSession); Router getRouter(); void fireUIInitListeners(UI ui); abstract URL getStaticResource(String url); abstract URL getResource(String url); abstract InputStream getResourceAsStream(String url); boolean isResourceAvailable(String url); abstract String resolveResource(String url); VaadinContext getContext(); BootstrapInitialPredicate getBootstrapInitialPredicate(); void setBootstrapInitialPredicate(
            BootstrapInitialPredicate bootstrapInitialPredicate); BootstrapUrlPredicate getBootstrapUrlPredicate(); void setBootstrapUrlPredicate(
            BootstrapUrlPredicate bootstrapUrlPredicate); static String getCsrfTokenAttributeName(); static final String INVALID_ATMOSPHERE_VERSION_WARNING; static final String ATMOSPHERE_MISSING_ERROR; static final String CANNOT_ACQUIRE_CLASSLOADER_SEVERE; }
@Test public void should_reported_routing_server() { VaadinServiceInitListener initListener = event -> { RouteConfiguration.forApplicationScope().setRoute("test", TestView.class); }; MockInstantiator instantiator = new MockInstantiator(initListener); MockVaadinServletService service = new MockVaadinServletService(); service.init(instantiator); Assert.assertTrue(UsageStatistics.getEntries().anyMatch( e -> Constants.STATISTIC_ROUTING_SERVER.equals(e.getName()))); }
@Test public void should_reported_routing_hybrid() { VaadinServiceInitListener initListener = event -> { RouteConfiguration.forApplicationScope().setRoute("test", TestView.class); }; UsageStatistics.markAsUsed(Constants.STATISTIC_ROUTING_CLIENT, Version.getFullVersion()); MockInstantiator instantiator = new MockInstantiator(initListener); MockVaadinServletService service = new MockVaadinServletService(); service.init(instantiator); Assert.assertTrue(UsageStatistics.getEntries().anyMatch( e -> Constants.STATISTIC_ROUTING_HYBRID.equals(e.getName()))); Assert.assertFalse(UsageStatistics.getEntries().anyMatch( e -> Constants.STATISTIC_ROUTING_CLIENT.equals(e.getName()))); Assert.assertFalse(UsageStatistics.getEntries().anyMatch( e -> Constants.STATISTIC_ROUTING_SERVER.equals(e.getName()))); }