Package io.permazen.spring
Class AnnotatedClassScanner
java.lang.Object
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
io.permazen.spring.AnnotatedClassScanner
- All Implemented Interfaces:
Aware
,ResourceLoaderAware
,EnvironmentCapable
- Direct Known Subclasses:
PermazenClassScanner
Scans the classpath for classes having one or more configured type annotations.
-
Field Summary
Fields inherited from class org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
IGNORE_CLASSFORMAT_PROPERTY_NAME, logger
-
Constructor Summary
ConstructorDescriptionAnnotatedClassScanner
(ClassLoader loader, boolean useDefaultFilters, Environment environment, Class<?>... annotationTypes) Constructor.AnnotatedClassScanner
(ClassLoader loader, Class<?>... annotationTypes) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
initializeResourceLoader
(ClassLoader loader) protected void
Register default include/exclude filters.scanForClasses
(String... basePackages) Locate annotated classes on the classpath.Methods inherited from class org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
addExcludeFilter, addIncludeFilter, clearCache, findCandidateComponents, getEnvironment, getMetadataReaderFactory, getRegistry, getResourceLoader, isCandidateComponent, isCandidateComponent, resetFilters, resolveBasePackage, setEnvironment, setMetadataReaderFactory, setResourceLoader, setResourcePattern
-
Constructor Details
-
AnnotatedClassScanner
Constructor. Enables use of default filters and uses aStandardEnvironment
.- Parameters:
loader
-ClassLoader
to use for finding classesannotationTypes
- type annotations to search for- Throws:
IllegalArgumentException
- ifannotationTypes
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 classesuseDefaultFilters
- whether to register the default filters for the specifiedannotationTypes
environment
- environment to useannotationTypes
- type annotations to search for- Throws:
IllegalArgumentException
- ifannotationTypes
is null, empty, or contains any non-annotation types
-
-
Method Details
-
scanForClasses
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
- ifbasePackages
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 classClassPathScanningCandidateComponentProvider
-
initializeResourceLoader
-