Class AnnotatedClassScanner

All Implemented Interfaces:
Aware, ResourceLoaderAware, EnvironmentCapable
Direct Known Subclasses:
PermazenClassScanner

public class AnnotatedClassScanner extends ClassPathScanningCandidateComponentProvider
Scans the classpath for classes having one or more configured type annotations.
  • Constructor Details

    • AnnotatedClassScanner

      public AnnotatedClassScanner(ClassLoader loader, Class<?>... annotationTypes)
      Constructor. Enables use of default filters and uses a StandardEnvironment.
      Parameters:
      loader - ClassLoader to use for finding classes
      annotationTypes - type annotations to search for
      Throws:
      IllegalArgumentException - if annotationTypes is null, empty, or contains any non-annotation types
    • AnnotatedClassScanner

      public AnnotatedClassScanner(ClassLoader loader, boolean useDefaultFilters, Environment environment, Class<?>... annotationTypes)
      Constructor.
      Parameters:
      loader - ClassLoader to use for finding classes
      useDefaultFilters - whether to register the default filters for the specified annotationTypes
      environment - environment to use
      annotationTypes - type annotations to search for
      Throws:
      IllegalArgumentException - if annotationTypes is null, empty, or contains any non-annotation types
  • Method Details

    • scanForClasses

      public ArrayList<String> scanForClasses(String... basePackages)
      Locate annotated classes on the classpath. Does not actually load the classes.
      Parameters:
      basePackages - one or more base pacakge names
      Returns:
      list of names of classes having any of the configured type annotations
      Throws:
      IllegalArgumentException - if basePackages is empty
    • registerDefaultFilters

      protected void registerDefaultFilters()
      Register default include/exclude filters.

      Overridden in AnnotatedClassScanner to set the default filters to be ones that match classes annotated with any of the annotation types provided to the constructor.

      Overrides:
      registerDefaultFilters in class ClassPathScanningCandidateComponentProvider
    • initializeResourceLoader

      protected void initializeResourceLoader(ClassLoader loader)