public class ScanSpec extends Object
Modifier and Type | Field | 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.
|
Set<String> |
blacklistedLibOrExtJarPaths |
Complete paths of blacklisted in the JDK/JRE "lib/" or "ext/" directory.
|
Set<String> |
blacklistedModules |
Names of blacklisted modules.
|
List<String> |
blacklistedPackagePrefixes |
Blacklisted package names with "." appended.
|
List<String> |
blacklistedPathPrefixes |
Blacklisted package paths with "/" appended.
|
boolean |
blacklistSystemJarsOrModules |
True if JRE system jarfiles (rt.jar etc.) should not be scanned.
|
List<FastClasspathScanner.ClasspathElementFilter> |
classpathElementFilters |
If non-null, a list of filter operations to apply to classpath elements.
|
boolean |
createClassLoaderForMatchingClasses |
If this method is called, a new
URLClassLoader is created for all classes found on the
classpath that match whitelist criteria. |
boolean |
disableRecursiveScanning |
Whether to disable recursive scanning (enabled by default).
|
boolean |
enableExternalClasses |
If true, allow external classes (classes outside of whitelisted packages) to be returned in the ScanResult,
if they are directly referred to by a whitelisted class, as a superclass, implemented interface or
annotation.
|
boolean |
enableFieldAnnotationIndexing |
If true, index field annotations.
|
boolean |
enableFieldInfo |
If true, enables the saving of field info during the scan.
|
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 |
stripSFXHeader |
If true, manually strip the self extracting executable header from zipfiles (i.e.
|
boolean |
suppressMatchProcessorExceptions |
If true, exceptions thrown inside MatchProcessors are not re-thrown wrapped in a MatchProcessorException at
the end of the scan, and the exceptions can be fetched using ScanResult.getMatchProcessorExceptions().
|
List<Pattern> |
whitelistedJarPatterns |
Whitelisted jarfile names containing a glob('*') character, converted to a regexp.
|
Set<String> |
whitelistedJars |
Whitelisted jarfile names.
|
Set<String> |
whitelistedLibOrExtJarPaths |
Complete paths of whitelisted jars to scan in the JDK/JRE "lib/" or "ext/" directory.
|
Set<String> |
whitelistedModules |
Names of whitelisted modules.
|
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 | Description |
---|---|
ScanSpec(String[] scanSpecFields,
LogNode log) |
Parses the scanning specification that was passed to the FastClasspathScanner constructor, and finds all
ClassLoaders.
|
Modifier and Type | Method | 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.
|
void |
filterClasspathElements(FastClasspathScanner.ClasspathElementFilter classpathElementFilter) |
Add a classpath element filter.
|
MultiMapKeyToSet<String,String> |
getClassNameToStaticFinalFieldsToMatch() |
Get the map from class name to static final fields to match.
|
boolean |
hasMatchProcessors() |
Return true if any MatchProcessors have been added.
|
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.
|
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(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.
|
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.
|
<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 List<String> whitelistedPathPrefixes
public List<String> whitelistedPathsNonRecursive
public transient List<String> blacklistedPathPrefixes
public List<String> blacklistedPackagePrefixes
public Set<String> specificallyWhitelistedClassRelativePaths
public transient Set<String> specificallyWhitelistedClassParentRelativePaths
public Set<String> specificallyBlacklistedClassRelativePaths
public Set<String> specificallyBlacklistedClassNames
public Set<String> whitelistedLibOrExtJarPaths
public Set<String> blacklistedLibOrExtJarPaths
public transient List<Pattern> whitelistedJarPatterns
public transient List<Pattern> blacklistedJarPatterns
public boolean scanJars
public boolean scanDirs
public boolean enableMethodAnnotationIndexing
public boolean enableFieldAnnotationIndexing
public boolean enableFieldInfo
public boolean enableMethodInfo
public boolean enableExternalClasses
public boolean blacklistSystemJarsOrModules
public boolean ignoreFieldVisibility
public boolean ignoreMethodVisibility
public RetentionPolicy annotationVisibility
public boolean disableRecursiveScanning
public boolean suppressMatchProcessorExceptions
public transient List<ClassLoader> addedClassLoaders
public transient List<ClassLoader> overrideClassLoaders
public String overrideClasspath
public transient List<FastClasspathScanner.ClasspathElementFilter> classpathElementFilters
public final transient ArrayList<ClassLoaderHandlerRegistry.ClassLoaderHandlerRegistryEntry> extraClassLoaderHandlers
public transient boolean initializeLoadedClasses
public transient boolean removeTemporaryFilesAfterScan
ScanResult
finalizer, or on JVM exit.public transient boolean ignoreParentClassLoaders
public transient boolean stripSFXHeader
public transient boolean createClassLoaderForMatchingClasses
URLClassLoader
is created for all classes found on the
classpath that match whitelist criteria. This may be needed if you get a ClassNotFoundException,
UnsatisfiedLinkError, NoClassDefFoundError, etc., due to trying to load classes that depend upon each other
but that are loaded by different ClassLoaders in the classpath.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)
overrideClasspath
- The classpath to scan.public void filterClasspathElements(FastClasspathScanner.ClasspathElementFilter classpathElementFilter)
classpathElementFilter
- The classpath element filter to apply to all discovered classpath elements, to decide which should
be scanned.public void addClassLoader(ClassLoader classLoader)
classLoader
- The classloader to add.public void overrideClassLoaders(ClassLoader... overrideClassLoaders)
overrideClassLoaders
- The classloaders to override the default context classloaders with.public boolean hasMatchProcessors()
public void callMatchProcessors(ScanResult scanResult)
scanResult
- The 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 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.