Package io.micronaut.ast.groovy.scan
Class ClassPathAnnotationScanner
- java.lang.Object
-
- io.micronaut.ast.groovy.scan.ClassPathAnnotationScanner
-
- All Implemented Interfaces:
io.micronaut.core.io.scan.AnnotationScanner
@Internal public class ClassPathAnnotationScanner extends java.lang.Object implements io.micronaut.core.io.scan.AnnotationScanner
An optimized classpath scanner that includes the ability to optionally scan JAR files.
The implementation avoids loading the classes themselves by parsing the class definitions and reading only the annotations.
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description ClassPathAnnotationScanner()
Default constructor.ClassPathAnnotationScanner(java.lang.ClassLoader classLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<java.lang.Class<?>>
doScan(java.lang.String annotation, java.lang.String pkg)
protected ClassPathAnnotationScanner
includeJars(boolean includeJars)
Whether to include JAR files.java.util.stream.Stream<java.lang.Class<?>>
scan(java.lang.String annotation, java.lang.String pkg)
Scan the given packages.protected void
scanFile(java.lang.String annotation, java.nio.file.Path filePath, java.util.List<java.lang.Class<?>> classes)
protected void
traverseFile(java.lang.String annotation, java.util.List<java.lang.Class<?>> classes, java.nio.file.Path filePath)
-
-
-
Method Detail
-
includeJars
protected ClassPathAnnotationScanner includeJars(boolean includeJars)
Whether to include JAR files.- Parameters:
includeJars
- The jar files to include- Returns:
- This scanner
-
scan
public java.util.stream.Stream<java.lang.Class<?>> scan(java.lang.String annotation, java.lang.String pkg)
Scan the given packages.- Specified by:
scan
in interfaceio.micronaut.core.io.scan.AnnotationScanner
- Parameters:
annotation
- The annotation to scan forpkg
- The package to scan- Returns:
- A stream of classes
-
doScan
protected java.util.List<java.lang.Class<?>> doScan(java.lang.String annotation, java.lang.String pkg)
- Parameters:
annotation
- The annotationpkg
- The package- Returns:
- The list of class
-
traverseFile
protected void traverseFile(java.lang.String annotation, java.util.List<java.lang.Class<?>> classes, java.nio.file.Path filePath)
- Parameters:
annotation
- The annotationclasses
- The classesfilePath
- The filePath
-
scanFile
protected void scanFile(java.lang.String annotation, java.nio.file.Path filePath, java.util.List<java.lang.Class<?>> classes)
- Parameters:
annotation
- The annotationfilePath
- The file pathclasses
- The classes
-
-