|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.xbean.finder.ClassFinder
public class ClassFinder
ClassFinder searches the classpath of the specified classloader for packages, classes, constructors, methods, or fields with specific annotations. For security reasons ASM is used to find the annotations. Classes are not loaded unless they match the requirements of a called findAnnotated* method. Once loaded, these classes are cached. The getClassesNotLoaded() method can be used immediately after any find* method to get a list of classes which matched the find requirements (i.e. contained the annotation), but were unable to be loaded.
Nested Class Summary | |
---|---|
class |
ClassFinder.Annotatable
|
class |
ClassFinder.AnnotationInfo
|
class |
ClassFinder.ClassInfo
|
class |
ClassFinder.FieldInfo
|
static interface |
ClassFinder.Info
|
class |
ClassFinder.InfoBuildingVisitor
|
class |
ClassFinder.MethodInfo
|
class |
ClassFinder.PackageInfo
|
Constructor Summary | |
---|---|
ClassFinder(java.lang.Class... classes)
|
|
ClassFinder(java.lang.ClassLoader classLoader)
Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the classloader's parent. |
|
ClassFinder(java.lang.ClassLoader classLoader,
boolean excludeParent)
Creates a ClassFinder that will search the urls in the specified classloader. |
|
ClassFinder(java.lang.ClassLoader classLoader,
java.lang.ClassLoader exclude)
Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the 'exclude' classloader. |
|
ClassFinder(java.lang.ClassLoader classLoader,
java.util.Collection<java.net.URL> urls)
|
|
ClassFinder(java.lang.ClassLoader classLoader,
java.net.URL url)
|
|
ClassFinder(java.util.List<java.lang.Class> classes)
|
Method Summary | |
---|---|
java.util.List<java.lang.Class> |
findAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
|
java.util.List<java.lang.reflect.Constructor> |
findAnnotatedConstructors(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
|
java.util.List<java.lang.reflect.Field> |
findAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
|
java.util.List<java.lang.reflect.Method> |
findAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
|
java.util.List<java.lang.Package> |
findAnnotatedPackages(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
|
java.util.List<java.lang.Class> |
findClassesInPackage(java.lang.String packageName,
boolean recursive)
|
java.util.List<java.lang.Class> |
findInheritedAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Naive implementation - works extremelly slow O(n^3) |
java.util.List<java.lang.String> |
getClassesNotLoaded()
Returns a list of classes that could not be loaded in last invoked findAnnotated* method. |
boolean |
isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassFinder(java.lang.ClassLoader classLoader) throws java.lang.Exception
classLoader
- source of classes to scan
java.lang.Exception
- if something goes wrongpublic ClassFinder(java.lang.ClassLoader classLoader, boolean excludeParent) throws java.lang.Exception
classLoader
- source of classes to scanexcludeParent
- Allegedly excludes classes from parent classloader, whatever that might mean
java.lang.Exception
- if something goes wrong.public ClassFinder(java.lang.ClassLoader classLoader, java.lang.ClassLoader exclude) throws java.lang.Exception
classLoader
- source of classes to scanexclude
- source of classes to exclude from scanning
java.lang.Exception
- if something goes wrongpublic ClassFinder(java.lang.ClassLoader classLoader, java.net.URL url)
public ClassFinder(java.lang.ClassLoader classLoader, java.util.Collection<java.net.URL> urls)
public ClassFinder(java.lang.Class... classes)
public ClassFinder(java.util.List<java.lang.Class> classes)
Method Detail |
---|
public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<java.lang.String> getClassesNotLoaded()
public java.util.List<java.lang.Package> findAnnotatedPackages(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<java.lang.Class> findAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<java.lang.Class> findInheritedAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
annotation
-
public java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<java.lang.reflect.Constructor> findAnnotatedConstructors(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<java.lang.reflect.Field> findAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public java.util.List<java.lang.Class> findClassesInPackage(java.lang.String packageName, boolean recursive)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |