@ComponentSpecification public interface ClasspathScanner
getClasspathResource*()
methods the entire classpath will be scanned and the
result will be cached. This is an expensive operation. However, after the results are cached further invocations are
relatively cheap. Please note that only the "directory structure" is kept in cache but not any content. Invocations
to read file contents from the classpath will always return the recent data without caching. If you have a dynamic
classpath where resources can be added at runtime see clearCaches()
. If you create and initialize the
implementation (manually or via Ioc
) it shall not scan the classpath or build
any caches before any of the actual getClasspathResource*()
methods are invoked.Modifier and Type | Method and Description |
---|---|
void |
clearCaches()
Evicts all cache data so that any further invocation of the other methods will rebuild the cached data from
scratch.
|
BrowsableResource |
getClasspathResource() |
BrowsableResource |
getClasspathResource(Package pkg) |
BrowsableResource |
getClasspathResource(String classpath) |
Iterable<Class<?>> |
getClasspathResourceClasses(Filter<String> classnameFilter,
Filter<Class<?>> classFilter) |
Iterable<? extends BrowsableResource> |
getClasspathResourceFiles() |
Iterable<? extends BrowsableResource> |
getClasspathResourceFiles(Filter<? super BrowsableResource> filter) |
String |
getQualifiedName(DataResource classResource) |
<T> Class<T> |
loadClass(BrowsableResource classResource) |
BrowsableResource getClasspathResource()
BrowsableResource
for the root (or default) package.BrowsableResource getClasspathResource(String classpath)
classpath
- is the classpath location pointing to a Package
or
ClasspathResource
.BrowsableResource
for the given classpath
.BrowsableResource getClasspathResource(Package pkg)
pkg
- is the Package
to get.BrowsableResource
pointing to the given package.Iterable<? extends BrowsableResource> getClasspathResourceFiles()
Iterable<? extends BrowsableResource> getClasspathResourceFiles(Filter<? super BrowsableResource> filter)
filter
- decides which file resources
to accept
. Please note that the name
of the filtered resources will end
with ".class" in case of a Class
.Iterable
with all resource files
on the classpath
accepted
by the given filter
.Iterable<Class<?>> getClasspathResourceClasses(Filter<String> classnameFilter, Filter<Class<?>> classFilter)
String getQualifiedName(DataResource classResource)
classResource
- a DataResource
that identifies a Java *.class
file or a Package
from your classpath. Should be retrieved from this ClasspathScanner
.class name
or package name
.
Will be null
in case the given DataResource
is not pointing to a Class
or
Package
.<T> Class<T> loadClass(BrowsableResource classResource) throws IllegalArgumentException
T
- the generic type of the returned Class
for simplistic usage.classResource
- a BrowsableResource
that identifies a Java *.class file from your classpath. Should be
retrieved from this ClasspathScanner
.Class
.IllegalArgumentException
- if the given BrowsableResource
does not point to a *.class file.void clearCaches()
Copyright © 2001–2016 mmm-Team. All rights reserved.