private Optional<Class<?>> loadClass(ClassLoader classLoader, String className) { try { return Optional.of(classLoader.loadClass(className)); } catch (ClassNotFoundException e) { getLogger().warn( "Failed to load class {}, ignoring it when deploying Vaadin servlets", className, e); return Optional.empty(); } }
private void createAppServlet(ServletContext context) { if (!ApplicationRouteRegistry.getInstance(context).hasNavigationTargets()) { getLogger().info( "{} there are no navigation targets registered to the registry", SKIPPING_AUTOMATIC_SERVLET_REGISTRATION_BECAUSE); return; } ServletRegistration vaadinServlet = findVaadinServlet(context); if (vaadinServlet != null) { getLogger().info( "{} there is already a Vaadin servlet with the name {}", SKIPPING_AUTOMATIC_SERVLET_REGISTRATION_BECAUSE, vaadinServlet.getName()); return; } createServletIfNotExists(context, getClass().getName(), "/*"); }
private void createServletIfNotExists(ServletContext context, String name, String path) { ServletRegistration existingServlet = findServletByPathPart(context, path); if (existingServlet != null) { getLogger().info( "{} there is already a {} servlet with the name {} for path {} given", SKIPPING_AUTOMATIC_SERVLET_REGISTRATION_BECAUSE, existingServlet, existingServlet.getName(), path); return; } ServletRegistration.Dynamic registration = context.addServlet(name, VaadinServlet.class); if (registration == null) { // Not expected to ever happen getLogger().info("{} there is already a servlet with the name {}", SKIPPING_AUTOMATIC_SERVLET_REGISTRATION_BECAUSE, name); return; } getLogger().info( "Automatically deploying Vaadin servlet with name {} to {}", name, path); registration.setAsyncSupported(true); registration.addMapping(path); }