Class 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
    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.micronaut.core.io.scan.AnnotationScanner

        scan, scan, scan, scan, scan, scan, scan, scan
    • Constructor Detail

      • ClassPathAnnotationScanner

        public ClassPathAnnotationScanner​(java.lang.ClassLoader classLoader)
        Parameters:
        classLoader - The class loader
      • ClassPathAnnotationScanner

        public ClassPathAnnotationScanner()
        Default constructor.
    • 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 interface io.micronaut.core.io.scan.AnnotationScanner
        Parameters:
        annotation - The annotation to scan for
        pkg - 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 annotation
        pkg - 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 annotation
        classes - The classes
        filePath - 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 annotation
        filePath - The file path
        classes - The classes