public class ScanSpec extends Object
Modifier and Type | Field and Description |
---|---|
List<ClassLoader> |
addedClassLoaders
If non-null, specified manually-added classloaders that should be searched after the context classloader(s).
|
RetentionPolicy |
annotationVisibility
Annotation retention visibility: RetentionPolicy.CLASS matches all annotations (both RuntimeVisible and
RuntimeInvisible); RetentionPolicy.RUNTIME matches only RuntimeVisible annotations.
|
List<Pattern> |
blacklistedJarPatterns
Blacklisted jarfile names containing a glob('*') character, converted to a regexp.
|
Set<String> |
blacklistedJars
Blacklisted jarfile names.
|
List<String> |
blacklistedPackagePrefixes
Blacklisted package names with "." appended.
|
List<String> |
blacklistedPathPrefixes
Blacklisted package paths with "/" appended.
|
boolean |
blacklistSystemJars
True if JRE system jarfiles (rt.jar etc.) should not be scanned.
|
boolean |
blacklistSystemPackages
By default, blacklist all java.* and sun.* packages.
|
ClassLoaderFinder |
classLoaderFinder
The ClassLoader finder.
|
boolean |
disableRecursiveScanning
Whether to disable recursive scanning (enabled by default).
|
boolean |
enableFieldAnnotationIndexing
If true, index field annotations.
|
boolean |
enableFieldInfo
If true, enables the saving of field info during the scan.
|
boolean |
enableFieldTypeIndexing
If true, index types of fields.
|
boolean |
enableMethodAnnotationIndexing
If true, index method annotations.
|
boolean |
enableMethodInfo
If true, enables the saving of method info during the scan.
|
ArrayList<ClassLoaderHandlerRegistry.ClassLoaderHandlerRegistryEntry> |
extraClassLoaderHandlers
Manually-registered ClassLoaderHandlers.
|
boolean |
ignoreFieldVisibility
If true, ignore field visibility (affects finding classes with fields of a given type, and matching of static
final fields with constant initializers).
|
boolean |
ignoreMethodVisibility
If true, ignore method visibility (affects finding methods with annotations of a given type).
|
boolean |
ignoreParentClassLoaders
If true, do not fetch paths from parent classloaders.
|
boolean |
initializeLoadedClasses
If true, classes loaded with Class.forName() are initialized before passing class references to
MatchProcessors.
|
List<ClassLoader> |
overrideClassLoaders
If non-null, all ClassLoaders have been overriden.
|
String |
overrideClasspath
If non-null, specifies a classpath to override the default one.
|
boolean |
removeTemporaryFilesAfterScan
If true, nested jarfiles (jarfiles within jarfiles) that are extracted during scanning are removed from their
temporary directory (e.g.
|
boolean |
scanDirs
True if directories on the classpath should be scanned.
|
boolean |
scanJars
True if jarfiles on the classpath should be scanned.
|
Set<String> |
specificallyBlacklistedClassNames
Blacklisted class names.
|
Set<String> |
specificallyBlacklistedClassRelativePaths
Blacklisted class relative paths.
|
Set<String> |
specificallyWhitelistedClassParentRelativePaths
Path prefixes of whitelisted classes, or the empty list if none.
|
Set<String> |
specificallyWhitelistedClassRelativePaths
Whitelisted class names, or the empty list if none.
|
boolean |
strictWhitelist
If true, remove "external" classes from consideration (i.e.
|
List<Pattern> |
whitelistedJarPatterns
Whitelisted jarfile names containing a glob('*') character, converted to a regexp.
|
Set<String> |
whitelistedJars
Whitelisted jarfile names.
|
List<String> |
whitelistedPathPrefixes
Whitelisted package paths with "/" appended, or the empty list if all packages are whitelisted.
|
List<String> |
whitelistedPathsNonRecursive
Whitelisted package paths with "/" appended, or the empty list if all packages are whitelisted.
|
Constructor and Description |
---|
ScanSpec(String[] scanSpec,
LogNode log)
Parses the scanning specification that was passed to the FastClasspathScanner constructor, and finds all
ClassLoaders.
|
Modifier and Type | Method and Description |
---|---|
void |
addClassLoader(ClassLoader classLoader)
Add a ClassLoader to the list of ClassLoaders to scan.
|
void |
callMatchProcessors(ScanResult scanResult)
Run the MatchProcessors after a scan has completed.
|
MultiMapKeyToSet<String,String> |
getClassNameToStaticFinalFieldsToMatch() |
boolean |
hasMatchProcessors()
Return true if any MatchProcessors have been added.
|
void |
ignoreParentClassLoaders(boolean ignoreParentClassloaders) |
void |
matchAllAnnotationClasses(ClassMatchProcessor classMatchProcessor)
Calls the provided ClassMatchProcessor for all annotation classes (annotation definitions) found in
whitelisted packages on the classpath.
|
void |
matchAllClasses(ClassMatchProcessor classMatchProcessor)
Calls the provided ClassMatchProcessor for all standard classes, interfaces and annotations found in
whitelisted packages on the classpath.
|
void |
matchAllInterfaceClasses(ClassMatchProcessor classMatchProcessor)
Calls the provided ClassMatchProcessor for all interface classes (interface definitions) found in whitelisted
packages on the classpath.
|
void |
matchAllStandardClasses(ClassMatchProcessor classMatchProcessor)
Calls the provided ClassMatchProcessor for all standard classes (i.e.
|
<T> void |
matchClassesImplementing(Class<T> implementedInterface,
ImplementingClassMatchProcessor<T> implementingClassMatchProcessor)
Calls the provided InterfaceMatchProcessor for classes on the classpath that implement the specified
interface or a subinterface, or whose superclasses implement the specified interface or a sub-interface.
|
void |
matchClassesWithAnnotation(Class<?> annotation,
ClassAnnotationMatchProcessor classAnnotationMatchProcessor)
Calls the provided ClassAnnotationMatchProcessor if classes are found on the classpath that have the
specified annotation.
|
void |
matchClassesWithFieldAnnotation(Class<? extends Annotation> annotation,
FieldAnnotationMatchProcessor fieldAnnotationMatchProcessor)
Calls the provided FieldAnnotationMatchProcessor if classes are found on the classpath that have one or more
fields with the specified annotation.
|
<T> void |
matchClassesWithFieldOfType(Class<T> fieldType,
ClassMatchProcessor classMatchProcessor)
Calls the provided ClassMatchProcessor for classes on the classpath that have a field of the given type.
|
void |
matchClassesWithMethodAnnotation(Class<? extends Annotation> annotation,
MethodAnnotationMatchProcessor methodAnnotationMatchProcessor)
Calls the provided MethodAnnotationMatchProcessor if classes are found on the classpath that have one or more
methods with the specified annotation.
|
void |
matchFilenameExtension(String extensionToMatch,
FileMatchProcessorAny fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath that have the given file extension.
|
void |
matchFilenamePath(String relativePathToMatch,
FileMatchProcessorAny fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath that exactly match the given relative
path.
|
void |
matchFilenamePathLeaf(String pathLeafToMatch,
FileMatchProcessorAny fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath that exactly match the given path
leafname.
|
void |
matchFilenamePattern(String pathRegexp,
FileMatchProcessorAny fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath with the given regexp pattern in their
path.
|
void |
matchStaticFinalFieldNames(Set<String> fullyQualifiedStaticFinalFieldNames,
StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
Calls the given StaticFinalFieldMatchProcessor if classes are found on the classpath that contain static
final fields that match one of a set of fully-qualified field names, e.g.
|
void |
matchStaticFinalFieldNames(String[] fullyQualifiedStaticFinalFieldNames,
StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
Calls the given StaticFinalFieldMatchProcessor if classes are found on the classpath that contain static
final fields that match one of a list of fully-qualified field names, e.g.
|
void |
matchStaticFinalFieldNames(String fullyQualifiedStaticFinalFieldName,
StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
Calls the given StaticFinalFieldMatchProcessor if classes are found on the classpath that contain static
final fields that match a fully-qualified field name, e.g.
|
<T> void |
matchSubclassesOf(Class<T> superclass,
SubclassMatchProcessor<T> subclassMatchProcessor)
Calls the provided SubclassMatchProcessor if classes are found on the classpath that extend the specified
superclass.
|
<T> void |
matchSubinterfacesOf(Class<T> superinterface,
SubinterfaceMatchProcessor<T> subinterfaceMatchProcessor)
Calls the provided SubinterfaceMatchProcessor if an interface that extends a given superinterface is found on
the classpath.
|
void |
overrideClassLoaders(ClassLoader... overrideClassLoaders)
Completely override the list of ClassLoaders to scan.
|
void |
overrideClasspath(String overrideClasspath)
Override the automatically-detected classpath with a custom search path.
|
void |
registerClassLoaderHandler(Class<? extends ClassLoaderHandler> classLoaderHandler)
Register an extra ClassLoaderHandler.
|
public final List<String> whitelistedPathPrefixes
public final List<String> whitelistedPathsNonRecursive
public final List<String> blacklistedPathPrefixes
public final List<String> blacklistedPackagePrefixes
public final Set<String> specificallyWhitelistedClassRelativePaths
public final Set<String> specificallyWhitelistedClassParentRelativePaths
public final Set<String> specificallyBlacklistedClassRelativePaths
public final Set<String> specificallyBlacklistedClassNames
public final Set<String> whitelistedJars
public final Set<String> blacklistedJars
public final List<Pattern> whitelistedJarPatterns
public final List<Pattern> blacklistedJarPatterns
public boolean scanJars
public boolean scanDirs
public boolean enableFieldTypeIndexing
public boolean enableMethodAnnotationIndexing
public boolean enableFieldAnnotationIndexing
public boolean enableFieldInfo
public boolean enableMethodInfo
public boolean strictWhitelist
public boolean blacklistSystemJars
public boolean blacklistSystemPackages
public boolean ignoreFieldVisibility
public boolean ignoreMethodVisibility
public RetentionPolicy annotationVisibility
public boolean disableRecursiveScanning
public List<ClassLoader> addedClassLoaders
public List<ClassLoader> overrideClassLoaders
public ClassLoaderFinder classLoaderFinder
public String overrideClasspath
public final ArrayList<ClassLoaderHandlerRegistry.ClassLoaderHandlerRegistryEntry> extraClassLoaderHandlers
public boolean initializeLoadedClasses
public boolean removeTemporaryFilesAfterScan
public boolean ignoreParentClassLoaders
public MultiMapKeyToSet<String,String> getClassNameToStaticFinalFieldsToMatch()
public void registerClassLoaderHandler(Class<? extends ClassLoaderHandler> classLoaderHandler)
classLoaderHandler
- The class of the ClassLoaderHandler that can handle those ClassLoaders.public void overrideClasspath(String overrideClasspath)
public void addClassLoader(ClassLoader classLoader)
public void overrideClassLoaders(ClassLoader... overrideClassLoaders)
public void ignoreParentClassLoaders(boolean ignoreParentClassloaders)
public boolean hasMatchProcessors()
public void callMatchProcessors(ScanResult scanResult)
public void matchAllClasses(ClassMatchProcessor classMatchProcessor)
classMatchProcessor
- the ClassMatchProcessor to call when a match is found.public void matchAllStandardClasses(ClassMatchProcessor classMatchProcessor)
classMatchProcessor
- the ClassMatchProcessor to call when a match is found.public void matchAllInterfaceClasses(ClassMatchProcessor classMatchProcessor)
classMatchProcessor
- the ClassMatchProcessor to call when a match is found.public void matchAllAnnotationClasses(ClassMatchProcessor classMatchProcessor)
classMatchProcessor
- the ClassMatchProcessor to call when a match is found.public <T> void matchSubclassesOf(Class<T> superclass, SubclassMatchProcessor<T> subclassMatchProcessor)
superclass
- The superclass to match (i.e. the class that subclasses need to extend to match).subclassMatchProcessor
- the SubclassMatchProcessor to call when a match is found.public <T> void matchSubinterfacesOf(Class<T> superinterface, SubinterfaceMatchProcessor<T> subinterfaceMatchProcessor)
superinterface
- The superinterface to match (i.e. the interface that subinterfaces need to extend to match).subinterfaceMatchProcessor
- the SubinterfaceMatchProcessor to call when a match is found.public <T> void matchClassesImplementing(Class<T> implementedInterface, ImplementingClassMatchProcessor<T> implementingClassMatchProcessor)
implementedInterface
- The interface that classes need to implement.implementingClassMatchProcessor
- the ClassMatchProcessor to call when a match is found.public <T> void matchClassesWithFieldOfType(Class<T> fieldType, ClassMatchProcessor classMatchProcessor)
fieldType
- The type of the field to match..classMatchProcessor
- the ClassMatchProcessor to call when a match is found.public void matchClassesWithAnnotation(Class<?> annotation, ClassAnnotationMatchProcessor classAnnotationMatchProcessor)
annotation
- The class annotation to match.classAnnotationMatchProcessor
- the ClassAnnotationMatchProcessor to call when a match is found.public void matchClassesWithMethodAnnotation(Class<? extends Annotation> annotation, MethodAnnotationMatchProcessor methodAnnotationMatchProcessor)
annotation
- The method annotation to match.methodAnnotationMatchProcessor
- the MethodAnnotationMatchProcessor to call when a match is found.public void matchClassesWithFieldAnnotation(Class<? extends Annotation> annotation, FieldAnnotationMatchProcessor fieldAnnotationMatchProcessor)
annotation
- The method annotation to match.fieldAnnotationMatchProcessor
- the FieldAnnotationMatchProcessor to call when a match is found.public void matchStaticFinalFieldNames(Set<String> fullyQualifiedStaticFinalFieldNames, StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
Field values are obtained from the constant pool in classfiles, not from a loaded class using reflection. This allows you to detect changes to the classpath and then run another scan that picks up the new values of selected static constants without reloading the class. (Class reloading is fraught with issues, see: http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html )
Note: Only static final fields with constant-valued literals are matched, not fields with initializer values that are the result of an expression or reference, except for cases where the compiler is able to simplify an expression into a single constant at compiletime, such as in the case of string concatenation.
Note that the visibility of the fields is not checked if ignoreFieldVisibility() was called before scan().
fullyQualifiedStaticFinalFieldNames
- The set of fully-qualified static field names to match.staticFinalFieldMatchProcessor
- the StaticFinalFieldMatchProcessor to call when a match is found.public void matchStaticFinalFieldNames(String fullyQualifiedStaticFinalFieldName, StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
Field values are obtained from the constant pool in classfiles, *not* from a loaded class using reflection. This allows you to detect changes to the classpath and then run another scan that picks up the new values of selected static constants without reloading the class. (Class reloading is fraught with issues, see: http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html )
Note: Only static final fields with constant-valued literals are matched, not fields with initializer values that are the result of an expression or reference, except for cases where the compiler is able to simplify an expression into a single constant at compiletime, such as in the case of string concatenation.
Note that the visibility of the fields is not checked if ignoreFieldVisibility() was called before scan().
fullyQualifiedStaticFinalFieldName
- The fully-qualified static field name to matchstaticFinalFieldMatchProcessor
- the StaticFinalFieldMatchProcessor to call when a match is found.public void matchStaticFinalFieldNames(String[] fullyQualifiedStaticFinalFieldNames, StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
Field values are obtained from the constant pool in classfiles, *not* from a loaded class using reflection. This allows you to detect changes to the classpath and then run another scan that picks up the new values of selected static constants without reloading the class. (Class reloading is fraught with issues, see: http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html )
Note: Only static final fields with constant-valued literals are matched, not fields with initializer values that are the result of an expression or reference, except for cases where the compiler is able to simplify an expression into a single constant at compiletime, such as in the case of string concatenation.
Note that the visibility of the fields is not checked if ignoreFieldVisibility() was called before scan().
fullyQualifiedStaticFinalFieldNames
- The list of fully-qualified static field names to match.staticFinalFieldMatchProcessor
- the StaticFinalFieldMatchProcessor to call when a match is found.public void matchFilenamePattern(String pathRegexp, FileMatchProcessorAny fileMatchProcessor)
pathRegexp
- The regexp to match, e.g. "app/templates/.\*\.html"fileMatchProcessor
- The FileMatchProcessor to call when each match is found.public void matchFilenamePath(String relativePathToMatch, FileMatchProcessorAny fileMatchProcessor)
relativePathToMatch
- The complete path to match relative to the classpath entry, e.g.
"app/templates/WidgetTemplate.html"fileMatchProcessor
- The FileMatchProcessor to call when each match is found.public void matchFilenamePathLeaf(String pathLeafToMatch, FileMatchProcessorAny fileMatchProcessor)
pathLeafToMatch
- The complete path leaf to match, e.g. "WidgetTemplate.html"fileMatchProcessor
- The FileMatchProcessor to call when each match is found.public void matchFilenameExtension(String extensionToMatch, FileMatchProcessorAny fileMatchProcessor)
extensionToMatch
- The extension to match, e.g. "html" matches "WidgetTemplate.html" and "WIDGET.HTML".fileMatchProcessor
- The FileMatchProcessor to call when each match is found.Copyright © 2018. All rights reserved.