public abstract class ClassFinder
extends java.lang.Object
URLs for classes.
Its purpose is to help scanning class paths for some classes.
Content of Jar files is also examined.
All paths are matched using path-style
wildcard matcher. All entries are matched using common-style
wildcard matcher.
ClassScanner| Modifier and Type | Class and Description |
|---|---|
protected static class |
ClassFinder.EntryData
Provides input stream on demand.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String[] |
excludedEntries |
protected java.lang.String[] |
excludedJars
Array of excluded jars.
|
protected boolean |
ignoreException
If set to
true exceptions for entry scans are ignored. |
protected java.lang.String[] |
includedEntries |
protected java.lang.String[] |
includedJars
Array of jar file name patterns that are included in the search.
|
protected boolean |
includeResources
If set to
true all files will be scanned and not only classes. |
protected static java.lang.String[] |
systemJars
Array of system jars that are excluded from the search.
|
| Constructor and Description |
|---|
ClassFinder() |
| 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. |
java.lang.String[] |
getExcludedEntries() |
java.lang.String[] |
getExcludedJars() |
java.lang.String[] |
getIncludedEntries() |
java.lang.String[] |
getIncludedJars() |
static java.lang.String[] |
getSystemJars()
Returns system jars.
|
protected byte[] |
getTypeSignatureBytes(java.lang.Class type)
Returns type signature bytes used for searching in class file.
|
boolean |
isIgnoreException() |
boolean |
isIncludeResources() |
protected boolean |
isTypeSignatureInUse(java.io.InputStream inputStream,
byte[] bytes)
Returns
true if class contains type signature. |
protected abstract void |
onEntry(ClassFinder.EntryData entryData)
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.
|
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.
|
protected void |
scanEntry(ClassFinder.EntryData entryData)
If entry name is
accepted invokes onEntry(EntryData) a callback}. |
protected void |
scanJarFile(java.io.File file)
Scans classes inside single JAR archive.
|
protected void |
scanPath(java.io.File file)
Scans single path.
|
protected void |
scanPath(java.lang.String path) |
protected void |
scanPaths(java.io.File... paths) |
protected void |
scanPaths(java.lang.String... paths) |
protected void |
scanUrl(java.net.URL url)
Scans single URL for classes and jar files.
|
protected void |
scanUrls(java.net.URL... urls)
Scans several URLs.
|
void |
setExcludedEntries(java.lang.String... excludedEntries)
Sets excluded names that narrows included set of packages.
|
void |
setExcludedJars(java.lang.String... excludedJars) |
void |
setIgnoreException(boolean ignoreException)
Sets if exceptions during scanning process should be ignored or not.
|
void |
setIncludedEntries(java.lang.String... includedEntries)
Sets included set of names that will be considered during configuration,
|
void |
setIncludedJars(java.lang.String... includedJars) |
void |
setIncludeResources(boolean includeResources) |
static void |
setSystemJars(java.lang.String... newSystemJars)
Specifies system jars, that are always excluded first.
|
protected static java.lang.String[] systemJars
protected java.lang.String[] excludedJars
protected java.lang.String[] includedJars
protected java.lang.String[] includedEntries
protected java.lang.String[] excludedEntries
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 java.lang.String[] getSystemJars()
public static void setSystemJars(java.lang.String... newSystemJars)
public java.lang.String[] getExcludedJars()
public void setExcludedJars(java.lang.String... excludedJars)
public java.lang.String[] getIncludedJars()
public void setIncludedJars(java.lang.String... includedJars)
public java.lang.String[] getIncludedEntries()
public void setIncludedEntries(java.lang.String... includedEntries)
public java.lang.String[] getExcludedEntries()
public void setExcludedEntries(java.lang.String... excludedEntries)
public boolean isIncludeResources()
public void setIncludeResources(boolean includeResources)
public boolean isIgnoreException()
public void setIgnoreException(boolean ignoreException)
protected void scanUrls(java.net.URL... urls)
protected void scanUrl(java.net.URL url)
onEntry(EntryData) is called on
each class name.protected void scanPaths(java.io.File... paths)
protected void scanPaths(java.lang.String... paths)
protected void scanPath(java.lang.String path)
protected boolean acceptJar(java.io.File jarFile)
true if some JAR file has to be accepted.
The following logic is provided by default, in given order:
protected void scanPath(java.io.File file)
protected void scanJarFile(java.io.File file)
onEntry(EntryData)protected void scanClassPath(java.io.File root)
onEntry(EntryData)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(ClassFinder.EntryData entryData)
accepted invokes onEntry(EntryData) a callback}.protected abstract void onEntry(ClassFinder.EntryData entryData) throws java.lang.Exception
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.java.lang.Exceptionprotected byte[] getTypeSignatureBytes(java.lang.Class type)
protected boolean isTypeSignatureInUse(java.io.InputStream inputStream,
byte[] bytes)
true if class contains type signature.
It searches the class content for bytecode signature. This is the fastest way of finding if come
class uses some type. Please note that if signature exists it still doesn't means that class uses
it in expected way, therefore, class should be loaded to complete the scan.Copyright © 2003-2013 Jodd Team