public class ClassScanner
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
ClassScanner.ClassPathEntry
Provides input stream on demand.
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String[] |
COMMONLY_EXCLUDED_ENTRIES |
protected static java.lang.String[] |
COMMONLY_EXCLUDED_JARS |
protected boolean |
detectEntriesMode |
protected boolean |
ignoreException
If set to
true exceptions for entry scans are ignored. |
protected boolean |
includeResources
If set to
true all files will be scanned and not only classes. |
protected InExRules<java.lang.String,java.lang.String,java.lang.String> |
rulesEntries |
protected InExRules<java.lang.String,java.lang.String,java.lang.String> |
rulesJars |
protected static java.lang.String[] |
SYSTEM_JARS
Array of system jars that are excluded from the search.
|
Constructor and Description |
---|
ClassScanner() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
acceptEntry(java.lang.String entryName)
Returns
true if some entry name has to be accepted. |
protected boolean |
acceptJar(java.io.File jarFile)
Returns
true if some JAR file has to be accepted. |
static byte[] |
bytecodeSignatureOfType(java.lang.Class type)
Returns type signature bytes used for searching in class file.
|
static ClassScanner |
create()
Create new class scanner.
|
ClassScanner |
detectEntriesMode(boolean detectMode) |
ClassScanner |
excludeAllEntries(boolean whitelist)
Sets white/black list mode for entries.
|
ClassScanner |
excludeAllJars(boolean whitelist)
Sets white/black list mode for jars.
|
ClassScanner |
excludeCommonEntries()
Excludes some commonly skipped packages.
|
ClassScanner |
excludeCommonJars()
Exclude some commonly unused jars.
|
ClassScanner |
excludeEntries(java.lang.String... excludedEntries)
Sets excluded names that narrows included set of packages.
|
ClassScanner |
excludeJars(java.lang.String... excludedJars)
Specify excluded jars.
|
ClassScanner |
ignoreException(boolean ignoreException)
Sets if exceptions during scanning process should be ignored or not.
|
ClassScanner |
includeAllEntries(boolean blacklist)
Sets white/black list mode for entries.
|
ClassScanner |
includeAllJars(boolean blacklist)
Sets white/black list mode for jars.
|
ClassScanner |
includeEntries(java.lang.String... includedEntries)
Sets included set of names that will be considered during configuration.
|
ClassScanner |
includeJars(java.lang.String... includedJars)
Specify included jars.
|
ClassScanner |
includeResources(boolean includeResources) |
protected void |
onEntry(ClassScanner.ClassPathEntry classPathEntry)
Called during classpath scanning when class or resource is found.
|
protected java.lang.String |
prepareEntryName(java.lang.String name,
boolean isClass)
Prepares resource and class names.
|
ClassScanner |
registerEntryConsumer(java.util.function.Consumer<ClassScanner.ClassPathEntry> entryDataConsumer)
Registers a
class path entry consumer. |
ClassScanner |
scan(java.io.File... paths)
Scans provided paths.
|
ClassScanner |
scan(java.lang.String... paths)
Scans provided paths.
|
ClassScanner |
scan(java.net.URL... urls)
Scans URLs.
|
protected void |
scanClassFile(java.lang.String filePath,
java.lang.String rootPath,
java.io.File file,
boolean isClass) |
protected void |
scanClassPath(java.io.File root)
Scans single classpath directory.
|
ClassScanner |
scanDefaultClasspath()
Scans
default class path . |
protected void |
scanEntry(ClassScanner.ClassPathEntry classPathEntry)
If entry name is
accepted invokes onEntry(ClassPathEntry) a callback}. |
protected void |
scanJarFile(java.io.File file)
Scans classes inside single JAR archive.
|
void |
start()
Starts with the scanner.
|
protected static final java.lang.String[] SYSTEM_JARS
protected static final java.lang.String[] COMMONLY_EXCLUDED_JARS
protected final InExRules<java.lang.String,java.lang.String,java.lang.String> rulesJars
protected static final java.lang.String[] COMMONLY_EXCLUDED_ENTRIES
protected final InExRules<java.lang.String,java.lang.String,java.lang.String> rulesEntries
protected boolean detectEntriesMode
protected boolean includeResources
true
all files will be scanned and not only classes.protected boolean ignoreException
true
exceptions for entry scans are ignored.public static ClassScanner create()
public ClassScanner excludeJars(java.lang.String... excludedJars)
public ClassScanner excludeCommonJars()
public ClassScanner includeJars(java.lang.String... includedJars)
public ClassScanner includeAllJars(boolean blacklist)
public ClassScanner excludeAllJars(boolean whitelist)
public ClassScanner includeEntries(java.lang.String... includedEntries)
InExRules
public ClassScanner includeAllEntries(boolean blacklist)
public ClassScanner excludeAllEntries(boolean whitelist)
public ClassScanner excludeEntries(java.lang.String... excludedEntries)
InExRules
public ClassScanner excludeCommonEntries()
public ClassScanner detectEntriesMode(boolean detectMode)
public ClassScanner includeResources(boolean includeResources)
public ClassScanner ignoreException(boolean ignoreException)
protected boolean acceptJar(java.io.File jarFile)
true
if some JAR file has to be accepted.protected void scanJarFile(java.io.File file)
onEntry(ClassPathEntry)
protected void scanClassPath(java.io.File root)
onEntry(ClassPathEntry)
protected void scanClassFile(java.lang.String filePath, java.lang.String rootPath, java.io.File file, boolean isClass)
protected java.lang.String prepareEntryName(java.lang.String name, boolean isClass)
protected boolean acceptEntry(java.lang.String entryName)
true
if some entry name has to be accepted.protected void scanEntry(ClassScanner.ClassPathEntry classPathEntry)
accepted
invokes onEntry(ClassPathEntry)
a callback}.public ClassScanner registerEntryConsumer(java.util.function.Consumer<ClassScanner.ClassPathEntry> entryDataConsumer)
class path entry
consumer.
It will be called on each loaded entry.protected void onEntry(ClassScanner.ClassPathEntry classPathEntry)
InputStream
is provided by InputStreamProvider and opened lazy.
Once opened, input stream doesn't have to be closed - this is done by this class anyway.public static byte[] bytecodeSignatureOfType(java.lang.Class type)
public ClassScanner scan(java.net.URL... urls)
public ClassScanner scanDefaultClasspath()
default class path
.public ClassScanner scan(java.io.File... paths)
public ClassScanner scan(java.lang.String... paths)
public void start()
Copyright © 2003-present Jodd Team