javax.servlet.annotation.HandlesTypes Java Examples
The following examples show how to use
javax.servlet.annotation.HandlesTypes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VaadinVerticle.java From vertx-vaadin with MIT License | 6 votes |
private void registerHandledTypes(ScanResult scanResult, Class<?> initializerClass, Map<Class<?>, Set<Class<?>>> map) { HandlesTypes handledTypes = initializerClass.getAnnotation(HandlesTypes.class); if (handledTypes != null) { Function<Class<?>, ClassInfoList> classFinder = type -> { if (type.isAnnotation()) { return scanResult.getClassesWithAnnotation(type.getCanonicalName()); } else if (type.isInterface()) { return scanResult.getClassesImplementing(type.getCanonicalName()); } else { return scanResult.getSubclasses(type.getCanonicalName()); } }; Set<Class<?>> classes = Stream.of(handledTypes.value()) .map(classFinder) .flatMap(c -> c.loadClasses().stream()) .collect(Collectors.toSet()); if (!classes.isEmpty()) { map.put(initializerClass, classes); } } }
Example #2
Source File: AbstractRouteRegistryInitializer.java From flow with Apache License 2.0 | 5 votes |
private Stream<Class<?>> getValidationAnnotations() { return Stream.concat( Stream.of(AnnotationValidator.class .getAnnotation(HandlesTypes.class).value()), Stream.of(WebComponentExporterAwareValidator.class .getAnnotation(HandlesTypes.class).value())); }
Example #3
Source File: ServletContainerInitializerRegistrationBean.java From joinfaces with Apache License 2.0 | 4 votes |
@Nullable protected Set<Class<?>> performClasspathScan() { HandlesTypes handlesTypes = AnnotationUtils.findAnnotation(getServletContainerInitializerClass(), HandlesTypes.class); if (handlesTypes == null) { return null; } Class<?>[] handledTypes = handlesTypes.value(); if (handledTypes.length == 0) { return null; } StopWatch stopWatch = new StopWatch(getServletContainerInitializerClass().getName()); stopWatch.start("prepare"); ClassGraph classGraph = new ClassGraph() .enableClassInfo(); // Only scan for Annotations if we have to if (Arrays.stream(handledTypes).anyMatch(Class::isAnnotation)) { classGraph = classGraph.enableAnnotationInfo(); } classGraph = classGraph.enableExternalClasses() .enableSystemJarsAndModules() // Find classes in javax.faces .blacklistPackages("java", "jdk", "sun", "javafx", "oracle") .blacklistPackages("javax.xml", "javax.el", "javax.persistence") .blacklistModules("java.*", "jdk.*") .filterClasspathElements(path -> { log.debug("Path {}", path); return true; }); Set<Class<?>> classes = new HashSet<>(); stopWatch.stop(); stopWatch.start("classpath scan"); try (ScanResult scanResult = classGraph.scan()) { stopWatch.stop(); stopWatch.start("collect results"); for (Class<?> handledType : handledTypes) { ClassInfoList classInfos; if (handledType.isAnnotation()) { classInfos = scanResult.getClassesWithAnnotation(handledType.getName()); } else if (handledType.isInterface()) { classInfos = scanResult.getClassesImplementing(handledType.getName()); } else { classInfos = scanResult.getSubclasses(handledType.getName()); } classes.addAll(classInfos.loadClasses()); } handleScanResult(scanResult); } finally { stopWatch.stop(); log.info("Resolving classes for {} took {}s", getServletContainerInitializerClass().getName(), stopWatch.getTotalTimeSeconds()); if (log.isDebugEnabled()) { log.debug(stopWatch.prettyPrint()); } } return classes.isEmpty() ? null : classes; }
Example #4
Source File: AnnotationValidator.java From flow with Apache License 2.0 | 4 votes |
@Override public List<Class<?>> getAnnotations() { return Arrays.asList( this.getClass().getAnnotation(HandlesTypes.class).value()); }
Example #5
Source File: DevModeInitializer.java From flow with Apache License 2.0 | 4 votes |
private static Set<String> calculateApplicableClassNames() { HandlesTypes handlesTypes = DevModeInitializer.class .getAnnotation(HandlesTypes.class); return Stream.of(handlesTypes.value()).map(Class::getName) .collect(Collectors.toSet()); }
Example #6
Source File: WebComponentExporterAwareValidator.java From flow with Apache License 2.0 | 4 votes |
@Override public List<Class<?>> getAnnotations() { return Arrays.asList( this.getClass().getAnnotation(HandlesTypes.class).value()); }
Example #7
Source File: DevModeClassFinderTest.java From flow with Apache License 2.0 | 4 votes |
private Collection<Class<?>> getApplicableClasses() { HandlesTypes handlesTypes = DevModeInitializer.class .getAnnotation(HandlesTypes.class); return Stream.of(handlesTypes.value()).collect(Collectors.toList()); }