public class ClassScanner extends Object
Constructor and Description |
---|
ClassScanner(ClassLoader... classLoaders) |
Modifier and Type | Method and Description |
---|---|
protected void |
addClassesForPackage(ClassResource classResource,
String filter,
Integer limit,
Set<Class<?>> classes) |
protected void |
addClassNamesInDirectoryWithMethodsAnnotatedWith(SortedSet<String> answer,
File dir,
Class<? extends Annotation> annotationClass,
String packageName) |
protected void |
addPackageResources(Package aPackage,
Map<String,ClassResource> urlSet,
ClassLoader[] classLoaders) |
protected boolean |
classNameMatches(String className,
String search)
Returns true if the given class name matches the filter search
|
void |
clearCache() |
protected CacheValue |
createCacheValue(String key,
ClassResource classResource) |
Class<?> |
findClass(String className)
Finds a class from its name
|
protected SortedSet<String> |
findClassNames(Map<Package,ClassLoader[]> packages,
Predicate<String> filter,
Integer limit) |
SortedSet<String> |
findClassNames(String search,
Integer limit)
Searches for the available class names given the text search
|
SortedSet<String> |
findClassNamesInDirectoryWithMethodAnnotatedWith(File dir,
String annotationClassName) |
SortedSet<String> |
findClassNamesInPackages(String search,
Integer limit,
Map<Package,ClassLoader[]> packages) |
SortedSet<String> |
findClassNamesMethodsAnnotatedWith(String annotationClassName) |
SortedSet<String> |
findClassNamesMethodsAnnotatedWith(String annotationClassName,
Integer limit,
Map<Package,ClassLoader[]> packages) |
SortedMap<String,Class<?>> |
getAllClassesMap()
Returns all the classes found in a sorted map
|
Set<Class<?>> |
getClassesForPackage(ClassResource classResource,
String filter,
Integer limit) |
SortedMap<String,Class<?>> |
getClassesMap(Package... packages)
Returns all the classes found in a sorted map for the given list of packages
|
List<ClassLoader> |
getClassLoaders() |
Set<String> |
getIgnorePackages() |
protected String |
getJavaResourceKey(URL resource) |
protected String |
getPackageRelativePath(String packageName) |
protected List<URL> |
getResources(String relPath,
ClassLoader... classLoaders) |
static ClassScanner |
newInstance() |
protected Class<? extends Annotation> |
optionallyFindAnnotationClass(String annotationClassName) |
Class<?> |
optionallyFindClass(String className)
Returns the given class or null if it cannot be loaded
|
List<Class<?>> |
optionallyFindClasses(Iterable<String> classNames)
Tries to find as many of the class names on the class loaders as possible and return them
|
protected void |
processDirectory(File directory,
String packageName,
Set<Class<?>> classes,
String filter,
Integer limit) |
protected void |
processDirectoryClassNames(File directory,
String packageName,
Set<String> classes) |
protected void |
processJar(ClassResource classResource,
Set<Class<?>> classes,
String filter,
Integer limit) |
protected void |
processJarClassNames(ClassResource classResource,
Set<String> classes) |
void |
setClassLoaderProvider(String id,
ClassLoaderProvider classLoaderProvider)
Registers a named class loader provider or removes it if the classLoaderProvider is null
|
void |
setIgnorePackages(Set<String> ignorePackages) |
protected Class<?> |
tryFindClass(String className,
String filter) |
protected boolean |
withinLimit(Integer limit,
Collection<?> collection)
Returns true if we are within the limit value for the number of results in the collection
|
public ClassScanner(ClassLoader... classLoaders)
public static ClassScanner newInstance()
public void clearCache()
public void setClassLoaderProvider(String id, ClassLoaderProvider classLoaderProvider)
public SortedSet<String> findClassNames(String search, Integer limit)
public SortedSet<String> findClassNamesMethodsAnnotatedWith(String annotationClassName)
public SortedSet<String> findClassNamesInDirectoryWithMethodAnnotatedWith(File dir, String annotationClassName)
protected void addClassNamesInDirectoryWithMethodsAnnotatedWith(SortedSet<String> answer, File dir, Class<? extends Annotation> annotationClass, String packageName)
protected Class<? extends Annotation> optionallyFindAnnotationClass(String annotationClassName)
public SortedSet<String> findClassNamesMethodsAnnotatedWith(String annotationClassName, Integer limit, Map<Package,ClassLoader[]> packages)
public SortedSet<String> findClassNamesInPackages(String search, Integer limit, Map<Package,ClassLoader[]> packages)
protected SortedSet<String> findClassNames(Map<Package,ClassLoader[]> packages, Predicate<String> filter, Integer limit)
public SortedMap<String,Class<?>> getAllClassesMap()
public SortedMap<String,Class<?>> getClassesMap(Package... packages)
public Set<Class<?>> getClassesForPackage(ClassResource classResource, String filter, Integer limit)
public Class<?> findClass(String className) throws ClassNotFoundException
ClassNotFoundException
public Class<?> optionallyFindClass(String className)
public List<Class<?>> optionallyFindClasses(Iterable<String> classNames)
protected void addPackageResources(Package aPackage, Map<String,ClassResource> urlSet, ClassLoader[] classLoaders)
protected CacheValue createCacheValue(String key, ClassResource classResource)
protected void processDirectoryClassNames(File directory, String packageName, Set<String> classes)
protected void processJarClassNames(ClassResource classResource, Set<String> classes)
protected void addClassesForPackage(ClassResource classResource, String filter, Integer limit, Set<Class<?>> classes)
protected void processDirectory(File directory, String packageName, Set<Class<?>> classes, String filter, Integer limit)
protected void processJar(ClassResource classResource, Set<Class<?>> classes, String filter, Integer limit)
protected List<URL> getResources(String relPath, ClassLoader... classLoaders)
protected boolean classNameMatches(String className, String search)
protected boolean withinLimit(Integer limit, Collection<?> collection)
public List<ClassLoader> getClassLoaders()
Copyright © 2020 JBoss by Red Hat. All rights reserved.