public class FastClasspathScanner extends Object
Constructor and Description |
---|
FastClasspathScanner(String... scanSpec)
Construct a FastClasspathScanner instance.
|
Modifier and Type | Method and Description |
---|---|
FastClasspathScanner |
addClassLoader(ClassLoader classLoader)
Add a ClassLoader to the list of ClassLoaders to scan.
|
FastClasspathScanner |
disableRecursiveScanning()
Disable recursive scanning.
|
FastClasspathScanner |
disableRecursiveScanning(boolean disableRecursiveScanning)
If true, disable recursive scanning.
|
FastClasspathScanner |
enableFieldTypeIndexing()
Enables field type indexing, which allows you to call ScanResult#getClassesWithFieldsOfType(type).
|
FastClasspathScanner |
enableFieldTypeIndexing(boolean enableFieldTypeIndexing)
If enableFieldTypeIndexing is true, enables field type indexing, which allows you to call
ScanResult#getClassesWithFieldsOfType(type).
|
FastClasspathScanner |
enableMethodAnnotationIndexing()
Enables method annotation indexing, which allows you to call
ScanResult#getClassesWithMethodAnnotations(annotationType).
|
FastClasspathScanner |
enableMethodAnnotationIndexing(boolean enableMethodAnnotationIndexing)
If enableMethodAnnotationIndexing is true, enables method annotation indexing, which allows you to call
ScanResult#getClassesWithMethodAnnotations(annotationType).
|
List<File> |
getUniqueClasspathElements()
Returns the list of all unique File objects representing directories or zip/jarfiles on the classpath, in
classloader resolution order.
|
List<File> |
getUniqueClasspathElements(ExecutorService executorService,
int numParallelTasks)
Returns the list of all unique File objects representing directories or zip/jarfiles on the classpath, in
classloader resolution order.
|
Future<List<File>> |
getUniqueClasspathElementsAsync(ExecutorService executorService,
int numParallelTasks)
Asynchronously returns the list of all unique File objects representing directories or zip/jarfiles on the
classpath, in classloader resolution order.
|
static String |
getVersion()
Get the version number of FastClasspathScanner.
|
FastClasspathScanner |
ignoreFieldVisibility()
This method causes FastClasspathScanner to ignore field visibility, enabling it to see private,
package-private and protected fields.
|
FastClasspathScanner |
ignoreFieldVisibility(boolean ignoreFieldVisibility)
If ignoreFieldVisibility is true, causes FastClasspathScanner to ignore field visibility, enabling it to see
private, package-private and protected fields.
|
FastClasspathScanner |
ignoreMethodVisibility()
This method causes FastClasspathScanner to ignore method visibility, enabling it to see private,
package-private and protected methods.
|
FastClasspathScanner |
ignoreMethodVisibility(boolean ignoreMethodVisibility)
If ignoreMethodVisibility is true, causes FastClasspathScanner to ignore method visibility, enabling it to
see private, package-private and protected methods.
|
FastClasspathScanner |
initializeLoadedClasses(boolean initializeLoadedClasses)
If initializeLoadedClasses is true, classes loaded with Class.forName() are initialized before passing class
references to MatchProcessors.
|
FastClasspathScanner |
matchAllAnnotationClasses(ClassMatchProcessor annotationClassMatchProcessor)
Calls the provided ClassMatchProcessor for all annotation classes (annotation definitions) found in
whitelisted packages on the classpath.
|
FastClasspathScanner |
matchAllClasses(ClassMatchProcessor classMatchProcessor)
Calls the provided ClassMatchProcessor for all standard classes, interfaces and annotations found in
whitelisted packages on the classpath.
|
FastClasspathScanner |
matchAllInterfaceClasses(ClassMatchProcessor interfaceClassMatchProcessor)
Calls the provided ClassMatchProcessor for all interface classes (interface definitions) found in whitelisted
packages on the classpath.
|
FastClasspathScanner |
matchAllStandardClasses(ClassMatchProcessor standardClassMatchProcessor)
Calls the provided ClassMatchProcessor for all standard classes (i.e.
|
<T> FastClasspathScanner |
matchClassesImplementing(Class<T> implementedInterface,
ImplementingClassMatchProcessor<T> interfaceMatchProcessor)
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.
|
FastClasspathScanner |
matchClassesWithAnnotation(Class<?> annotation,
ClassAnnotationMatchProcessor classAnnotationMatchProcessor)
Calls the provided ClassAnnotationMatchProcessor if classes are found on the classpath that have the
specified annotation.
|
<T> FastClasspathScanner |
matchClassesWithFieldOfType(Class<T> fieldType,
ClassMatchProcessor classMatchProcessor)
Calls the provided ClassMatchProcessor for classes on the classpath that have a field of the given type.
|
FastClasspathScanner |
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.
|
FastClasspathScanner |
matchFilenameExtension(String extensionToMatch,
FileMatchContentsProcessor fileMatchContentsProcessor)
Calls the given FileMatchProcessor if files are found on the classpath that have the given file extension.
|
FastClasspathScanner |
matchFilenameExtension(String extensionToMatch,
FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
Calls the given FileMatchProcessorWithContext if files are found on the classpath that have the given file
extension.
|
FastClasspathScanner |
matchFilenameExtension(String extensionToMatch,
FileMatchProcessor fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath that have the given file extension.
|
FastClasspathScanner |
matchFilenameExtension(String extensionToMatch,
FileMatchProcessorWithContext fileMatchProcessorWithContext)
Calls the given FileMatchProcessorWithContext if files are found on the classpath that have the given file
extension.
|
FastClasspathScanner |
matchFilenamePath(String relativePathToMatch,
FileMatchContentsProcessor fileMatchContentsProcessor)
Calls the given FileMatchContentsProcessor if files are found on the classpath that exactly match the given
relative path.
|
FastClasspathScanner |
matchFilenamePath(String relativePathToMatch,
FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
Calls the given FileMatchContentsProcessorWithContext if files are found on the classpath that exactly match
the given relative path.
|
FastClasspathScanner |
matchFilenamePath(String relativePathToMatch,
FileMatchProcessor fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath that exactly match the given relative
path.
|
FastClasspathScanner |
matchFilenamePath(String relativePathToMatch,
FileMatchProcessorWithContext fileMatchProcessorWithContext)
Calls the given FileMatchProcessorWithContext if files are found on the classpath that exactly match the
given relative path.
|
FastClasspathScanner |
matchFilenamePathLeaf(String pathLeafToMatch,
FileMatchContentsProcessor fileMatchContentsProcessor)
Calls the given FileMatchContentsProcessor if files are found on the classpath that exactly match the given
path leafname.
|
FastClasspathScanner |
matchFilenamePathLeaf(String pathLeafToMatch,
FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
Calls the given FileMatchContentsProcessorWithContext if files are found on the classpath that exactly match
the given path leafname.
|
FastClasspathScanner |
matchFilenamePathLeaf(String pathLeafToMatch,
FileMatchProcessor fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath that exactly match the given path
leafname.
|
FastClasspathScanner |
matchFilenamePathLeaf(String pathLeafToMatch,
FileMatchProcessorWithContext fileMatchProcessorWithContext)
Calls the given FileMatchProcessorWithContext if files are found on the classpath that exactly match the
given path leafname.
|
FastClasspathScanner |
matchFilenamePattern(String pathRegexp,
FileMatchContentsProcessor fileMatchContentsProcessor)
Calls the given FileMatchContentsProcessor if files are found on the classpath with the given regexp pattern
in their path.
|
FastClasspathScanner |
matchFilenamePattern(String pathRegexp,
FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
Calls the given FileMatchContentsProcessorWithContext if files are found on the classpath with the given
regexp pattern in their path.
|
FastClasspathScanner |
matchFilenamePattern(String pathRegexp,
FileMatchProcessor fileMatchProcessor)
Calls the given FileMatchProcessor if files are found on the classpath with the given regexp pattern in their
path.
|
FastClasspathScanner |
matchFilenamePattern(String pathRegexp,
FileMatchProcessorWithContext fileMatchProcessorWithContext)
Calls the given FileMatchProcessorWithContext if files are found on the classpath with the given regexp
pattern in their path.
|
FastClasspathScanner |
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.
|
FastClasspathScanner |
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.
|
FastClasspathScanner |
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> FastClasspathScanner |
matchSubclassesOf(Class<T> superclass,
SubclassMatchProcessor<T> subclassMatchProcessor)
Calls the provided SubclassMatchProcessor if classes are found on the classpath that extend the specified
superclass.
|
<T> FastClasspathScanner |
matchSubinterfacesOf(Class<T> superinterface,
SubinterfaceMatchProcessor<T> subinterfaceMatchProcessor)
Calls the provided SubinterfaceMatchProcessor if an interface that extends a given superinterface is found on
the classpath.
|
FastClasspathScanner |
overrideClassLoaders(ClassLoader... overrideClassLoaders)
Completely override (and ignore) system ClassLoaders and the java.class.path system property.
|
FastClasspathScanner |
overrideClasspath(Iterable<?> overrideClasspathElements)
Override the automatically-detected classpath with a custom path.
|
FastClasspathScanner |
overrideClasspath(Object... overrideClasspathElements)
Override the automatically-detected classpath with a custom path.
|
FastClasspathScanner |
overrideClasspath(String overrideClasspath)
Override the automatically-detected classpath with a custom path, with path elements separated by
File.pathSeparatorChar.
|
FastClasspathScanner |
registerClassLoaderHandler(Class<? extends ClassLoaderHandler> classLoaderHandlerClass)
Register an extra ClassLoaderHandler.
|
FastClasspathScanner |
removeTemporaryFilesAfterScan(boolean removeTemporaryFilesAfterScan)
If true (the default), nested jarfiles (jarfiles within jarfiles, which have to be extracted during scanning
in order to be read) are removed from their temporary directory after the scan has completed.
|
ScanResult |
scan()
Scans the classpath for matching files, and calls any MatchProcessors if a match is identified.
|
ScanResult |
scan(ExecutorService executorService,
int numParallelTasks)
Scans the classpath for matching files, and calls any MatchProcessors if a match is identified.
|
ScanResult |
scan(int numThreads)
Scans the classpath for matching files, and calls any MatchProcessors if a match is identified.
|
Future<ScanResult> |
scanAsync(ExecutorService executorService,
int numParallelTasks)
Asynchronously scans the classpath for matching files, and calls any MatchProcessors if a match is
identified.
|
FastClasspathScanner |
setAnnotationVisibility(RetentionPolicy annotationVisibility)
Set annotation visibility (to match the annotation retention policy).
|
FastClasspathScanner |
strictWhitelist()
Switches FastClasspathScanner to strict mode, which disallows searching/matching based on blacklisted
classes, and removes "external" classes from result lists returned by ScanSpec#get...() methods.
|
FastClasspathScanner |
strictWhitelist(boolean strictWhitelist)
If strictWhitelist is true, switches FastClasspathScanner to strict mode, which disallows searching/matching
based on blacklisted classes, and removes "external" classes from result lists returned by ScanSpec#get...()
methods.
|
FastClasspathScanner |
verbose()
Switches on verbose mode for debugging purposes.
|
FastClasspathScanner |
verbose(boolean verbose)
Switches on verbose mode for debugging purposes if verbose == true.
|
public FastClasspathScanner(String... scanSpec)
scanSpec
- The constructor accepts a list of whitelisted package prefixes / jar names to scan, as well as
blacklisted packages/jars not to scan, where blacklisted entries are prefixed with the '-'
character. See https://github.com/lukehutch/fast-classpath-scanner/wiki/2.-Constructor for info.public static final String getVersion()
public FastClasspathScanner verbose(boolean verbose)
verbose
- Whether or not to give verbose output.public FastClasspathScanner verbose()
public FastClasspathScanner ignoreFieldVisibility(boolean ignoreFieldVisibility)
ignoreFieldVisibility
- Whether or not to ignore the field visibility modifier.public FastClasspathScanner ignoreFieldVisibility()
public FastClasspathScanner ignoreMethodVisibility(boolean ignoreMethodVisibility)
ignoreMethodVisibility
- Whether or not to ignore the method visibility modifier.public FastClasspathScanner ignoreMethodVisibility()
public FastClasspathScanner enableFieldTypeIndexing(boolean enableFieldTypeIndexing)
enableFieldTypeIndexing
- Whether or not to enable field type indexing.public FastClasspathScanner enableFieldTypeIndexing()
public FastClasspathScanner enableMethodAnnotationIndexing(boolean enableMethodAnnotationIndexing)
enableMethodAnnotationIndexing
- Whether or not to enable method annotation indexing.public FastClasspathScanner enableMethodAnnotationIndexing()
public FastClasspathScanner strictWhitelist(boolean strictWhitelist)
strictWhitelist
- Whether or not to switch to strict mode.public FastClasspathScanner strictWhitelist()
public FastClasspathScanner initializeLoadedClasses(boolean initializeLoadedClasses)
initializeLoadedClasses
- Whether or not to initialize classes before passing class references to MatchProcessors. (The
default value is false.)public FastClasspathScanner removeTemporaryFilesAfterScan(boolean removeTemporaryFilesAfterScan)
removeTemporaryFilesAfterScan
- Whether or not to remove temporary files after scanning. (The default value is true.)public FastClasspathScanner disableRecursiveScanning()
public FastClasspathScanner disableRecursiveScanning(boolean disableRecursiveScanning)
disableRecursiveScanning
- Whether or not to disable recursive scanning. (The default value is false.)public FastClasspathScanner registerClassLoaderHandler(Class<? extends ClassLoaderHandler> classLoaderHandlerClass)
classLoaderHandlerClass
- The ClassLoaderHandler class to register.public FastClasspathScanner overrideClasspath(String overrideClasspath)
overrideClasspath
- The custom classpath to use for scanning, with path elements separated by File.pathSeparatorChar.public FastClasspathScanner overrideClasspath(Iterable<?> overrideClasspathElements)
overrideClasspathElements
- The custom classpath to use for scanning, with path elements separated by File.pathSeparatorChar.public FastClasspathScanner overrideClasspath(Object... overrideClasspathElements)
overrideClasspathElements
- The custom classpath to use for scanning, with path elements separated by File.pathSeparatorChar.public FastClasspathScanner addClassLoader(ClassLoader classLoader)
classLoader
- The additional ClassLoader to scan.public FastClasspathScanner overrideClassLoaders(ClassLoader... overrideClassLoaders)
overrideClassLoaders
- The ClassLoaders to scan instead of the automatically-detected ClassLoaders.public FastClasspathScanner matchAllClasses(ClassMatchProcessor classMatchProcessor)
classMatchProcessor
- the ClassMatchProcessor to call when a match is found.public FastClasspathScanner matchAllStandardClasses(ClassMatchProcessor standardClassMatchProcessor)
standardClassMatchProcessor
- the ClassMatchProcessor to call when a match is found.public FastClasspathScanner matchAllInterfaceClasses(ClassMatchProcessor interfaceClassMatchProcessor)
interfaceClassMatchProcessor
- the ClassMatchProcessor to call when a match is found.public FastClasspathScanner matchAllAnnotationClasses(ClassMatchProcessor annotationClassMatchProcessor)
annotationClassMatchProcessor
- the ClassMatchProcessor to call when a match is found.public <T> FastClasspathScanner 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> FastClasspathScanner 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> FastClasspathScanner matchClassesImplementing(Class<T> implementedInterface, ImplementingClassMatchProcessor<T> interfaceMatchProcessor)
implementedInterface
- The interface that classes need to implement.interfaceMatchProcessor
- the ClassMatchProcessor to call when a match is found.public <T> FastClasspathScanner 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 FastClasspathScanner matchClassesWithAnnotation(Class<?> annotation, ClassAnnotationMatchProcessor classAnnotationMatchProcessor)
annotation
- The class annotation to match.classAnnotationMatchProcessor
- the ClassAnnotationMatchProcessor to call when a match is found.public FastClasspathScanner matchClassesWithMethodAnnotation(Class<? extends Annotation> annotation, MethodAnnotationMatchProcessor methodAnnotationMatchProcessor)
annotation
- The method annotation to match.methodAnnotationMatchProcessor
- the MethodAnnotationMatchProcessor to call when a match is found.public FastClasspathScanner setAnnotationVisibility(RetentionPolicy annotationVisibility)
annotationVisibility
- The annotation visibility: RetentionPolicy.RUNTIME matches only runtime-visible annotations. The
default value, RetentionPolicy.CLASS, matches all annotations (both runtime-visible and
runtime-invisible). RetentionPolicy.SOURCE will cause an IllegalArgumentException to be thrown,
since SOURCE-annotated annotations are not retained in classfiles.public FastClasspathScanner matchStaticFinalFieldNames(Set<String> fullyQualifiedStaticFinalFieldNames, StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
fullyQualifiedStaticFinalFieldNames
- The set of fully-qualified static field names to match.staticFinalFieldMatchProcessor
- the StaticFinalFieldMatchProcessor to call when a match is found.public FastClasspathScanner matchStaticFinalFieldNames(String fullyQualifiedStaticFinalFieldName, StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
fullyQualifiedStaticFinalFieldName
- The fully-qualified static field name to matchstaticFinalFieldMatchProcessor
- the StaticFinalFieldMatchProcessor to call when a match is found.public FastClasspathScanner matchStaticFinalFieldNames(String[] fullyQualifiedStaticFinalFieldNames, StaticFinalFieldMatchProcessor staticFinalFieldMatchProcessor)
fullyQualifiedStaticFinalFieldNames
- The list of fully-qualified static field names to match.staticFinalFieldMatchProcessor
- the StaticFinalFieldMatchProcessor to call when a match is found.public FastClasspathScanner matchFilenamePattern(String pathRegexp, FileMatchProcessor fileMatchProcessor)
pathRegexp
- The regexp to match, e.g. "app/templates/.\*\.html"fileMatchProcessor
- The FileMatchProcessor to call when each match is found.public FastClasspathScanner matchFilenamePattern(String pathRegexp, FileMatchContentsProcessor fileMatchContentsProcessor)
pathRegexp
- The regexp to match, e.g. "app/templates/.\*\.html"fileMatchContentsProcessor
- The FileMatchContentsProcessor to call when each match is found.public FastClasspathScanner matchFilenamePattern(String pathRegexp, FileMatchProcessorWithContext fileMatchProcessorWithContext)
pathRegexp
- The regexp to match, e.g. "app/templates/.\*\.html"fileMatchProcessorWithContext
- The FileMatchProcessorWithContext to call when each match is found.public FastClasspathScanner matchFilenamePattern(String pathRegexp, FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
pathRegexp
- The regexp to match, e.g. "app/templates/.\*\.html"fileMatchContentsProcessorWithContext
- The FileMatchContentsProcessorWithContext to call when each match is found.public FastClasspathScanner matchFilenamePath(String relativePathToMatch, FileMatchProcessor 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 FastClasspathScanner matchFilenamePath(String relativePathToMatch, FileMatchContentsProcessor fileMatchContentsProcessor)
relativePathToMatch
- The complete path to match relative to the classpath entry, e.g.
"app/templates/WidgetTemplate.html"fileMatchContentsProcessor
- The FileMatchContentsProcessor to call when each match is found.public FastClasspathScanner matchFilenamePath(String relativePathToMatch, FileMatchProcessorWithContext fileMatchProcessorWithContext)
relativePathToMatch
- The complete path to match relative to the classpath entry, e.g.
"app/templates/WidgetTemplate.html"fileMatchProcessorWithContext
- The FileMatchProcessorWithContext to call when each match is found.public FastClasspathScanner matchFilenamePath(String relativePathToMatch, FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
relativePathToMatch
- The complete path to match relative to the classpath entry, e.g.
"app/templates/WidgetTemplate.html"fileMatchContentsProcessorWithContext
- The FileMatchContentsProcessorWithContext to call when each match is found.public FastClasspathScanner matchFilenamePathLeaf(String pathLeafToMatch, FileMatchProcessor fileMatchProcessor)
pathLeafToMatch
- The complete path leaf to match, e.g. "WidgetTemplate.html"fileMatchProcessor
- The FileMatchProcessor to call when each match is found.public FastClasspathScanner matchFilenamePathLeaf(String pathLeafToMatch, FileMatchContentsProcessor fileMatchContentsProcessor)
pathLeafToMatch
- The complete path leaf to match, e.g. "WidgetTemplate.html"fileMatchContentsProcessor
- The FileMatchContentsProcessor to call when each match is found.public FastClasspathScanner matchFilenamePathLeaf(String pathLeafToMatch, FileMatchProcessorWithContext fileMatchProcessorWithContext)
pathLeafToMatch
- The complete path leaf to match, e.g. "WidgetTemplate.html"fileMatchProcessorWithContext
- The FileMatchProcessorWithContext to call when each match is found.public FastClasspathScanner matchFilenamePathLeaf(String pathLeafToMatch, FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
pathLeafToMatch
- The complete path leaf to match, e.g. "WidgetTemplate.html"fileMatchContentsProcessorWithContext
- The FileMatchContentsProcessorWithContext to call when each match is found.public FastClasspathScanner matchFilenameExtension(String extensionToMatch, FileMatchProcessor 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.public FastClasspathScanner matchFilenameExtension(String extensionToMatch, FileMatchContentsProcessor fileMatchContentsProcessor)
extensionToMatch
- The extension to match, e.g. "html" matches "WidgetTemplate.html".fileMatchContentsProcessor
- The FileMatchContentsProcessor to call when each match is found.public FastClasspathScanner matchFilenameExtension(String extensionToMatch, FileMatchProcessorWithContext fileMatchProcessorWithContext)
extensionToMatch
- The extension to match, e.g. "html" matches "WidgetTemplate.html" and "WIDGET.HTML".fileMatchProcessorWithContext
- The FileMatchProcessorWithContext to call when each match is found.public FastClasspathScanner matchFilenameExtension(String extensionToMatch, FileMatchContentsProcessorWithContext fileMatchContentsProcessorWithContext)
extensionToMatch
- The extension to match, e.g. "html" matches "WidgetTemplate.html".fileMatchContentsProcessorWithContext
- The FileMatchContentsProcessorWithContext to call when each match is found.public Future<ScanResult> scanAsync(ExecutorService executorService, int numParallelTasks)
executorService
- A custom ExecutorService to use for scheduling worker tasks.numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of
classpath scanning. Ideally the ExecutorService will have at least this many threads available.public ScanResult scan(ExecutorService executorService, int numParallelTasks)
executorService
- A custom ExecutorService to use for scheduling worker tasks. This ExecutorService should start
tasks in FIFO order to avoid a deadlock during scan, i.e. be sure to construct the ExecutorService
with a LinkedBlockingQueue as its task queue. (This is the default for
Executors.newFixedThreadPool().)numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of
classpath scanning. Ideally the ExecutorService will have at least this many threads available.MatchProcessorException
- if classloading fails for any of the classes matched by a MatchProcessor, or if a MatchProcessor
throws an exception.ScanInterruptedException
- if any of the worker threads are interrupted during the scan. If you care about thread
interruption, you should catch this exception. If you don't plan to interrupt the scan, you
probably don't need to catch this.RuntimeException
- if any of the worker threads throws an uncaught exception. (Should not happen, this would
indicate a bug in FastClasspathScanner.)public ScanResult scan(int numThreads)
numThreads
- The number of worker threads to start up.MatchProcessorException
- if classloading fails for any of the classes matched by a MatchProcessor, or if a MatchProcessor
throws an exception.ScanInterruptedException
- if any of the worker threads are interrupted during the scan (shouldn't happen under normal
circumstances).RuntimeException
- if any of the worker threads throws an uncaught exception. (Should not happen, this would
indicate a bug in FastClasspathScanner.)public ScanResult scan()
MatchProcessorException
- if classloading fails for any of the classes matched by a MatchProcessor, or if a MatchProcessor
throws an exception.ScanInterruptedException
- if any of the worker threads are interrupted during the scan (shouldn't happen under normal
circumstances).RuntimeException
- if any of the worker threads throws an uncaught exception. (Should not happen, this would
indicate a bug in FastClasspathScanner.)public Future<List<File>> getUniqueClasspathElementsAsync(ExecutorService executorService, int numParallelTasks)
executorService
- A custom ExecutorService to use for scheduling worker tasks.numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of
classpath scanning. Ideally the ExecutorService will have at least this many threads available.public List<File> getUniqueClasspathElements(ExecutorService executorService, int numParallelTasks)
executorService
- A custom ExecutorService to use for scheduling worker tasks.numParallelTasks
- The number of parallel tasks to break the work into during the most CPU-intensive stage of
classpath scanning. Ideally the ExecutorService will have at least this many threads available.ScanInterruptedException
- if any of the worker threads are interrupted during the scan. If you care about thread
interruption, you should catch this exception. If you don't plan to interrupt the scan, you
probably don't need to catch this.public List<File> getUniqueClasspathElements()
ScanInterruptedException
- if any of the worker threads are interrupted during the scan (shouldn't happen under normal
circumstances).Copyright © 2017. All rights reserved.