Package org.apache.xbean.finder
Class AbstractFinder
- java.lang.Object
-
- org.apache.xbean.finder.AbstractFinder
-
- All Implemented Interfaces:
IAnnotationFinder
- Direct Known Subclasses:
ClassFinder
public abstract class AbstractFinder extends java.lang.Object implements IAnnotationFinder
- Version:
- $Rev: 1881759 $ $Date: 2020-09-16 10:29:43 +0200 (Wed, 16 Sep 2020) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AbstractFinder.Annotatable
class
AbstractFinder.AnnotationInfo
class
AbstractFinder.ClassInfo
class
AbstractFinder.FieldInfo
static interface
AbstractFinder.Info
class
AbstractFinder.InfoBuildingVisitor
class
AbstractFinder.MethodInfo
class
AbstractFinder.PackageInfo
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.util.List<AbstractFinder.Info>>
annotated
private int
ASM_FLAGS
private java.util.List<java.lang.String>
classesNotLoaded
protected java.util.Map<java.lang.String,AbstractFinder.ClassInfo>
classInfos
protected java.util.Map<java.lang.String,AbstractFinder.ClassInfo>
originalInfos
-
Constructor Summary
Constructors Constructor Description AbstractFinder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private <T> java.util.List<java.lang.Class<? extends T>>
_findSubclasses(java.lang.Class<T> clazz)
private java.util.List<AbstractFinder.ClassInfo>
collectImplementations(java.lang.String interfaceName)
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)
<T> java.util.List<java.lang.Class<? extends T>>
findImplementations(java.lang.Class<T> clazz)
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<Annotated<java.lang.Class<?>>>
findMetaAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
java.util.List<Annotated<java.lang.reflect.Field>>
findMetaAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
java.util.List<Annotated<java.lang.reflect.Method>>
findMetaAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
<T> java.util.List<java.lang.Class<? extends T>>
findSubclasses(java.lang.Class<T> clazz)
private <T> void
findSubclasses(AbstractFinder.ClassInfo classInfo, java.util.List<java.lang.Class<? extends T>> found, java.lang.Class<T> clazz)
java.util.List<java.lang.String>
getAnnotatedClassNames()
protected java.util.List<AbstractFinder.Info>
getAnnotationInfos(java.lang.String name)
java.util.List<java.lang.String>
getClassesNotLoaded()
Returns a list of classes that could not be loaded in last invoked findAnnotated* method.protected abstract java.net.URL
getResource(java.lang.String className)
boolean
isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
AbstractFinder
link()
The link() method must be called to successfully use the findSubclasses and findImplementations methodsprivate void
linkInterfaces(AbstractFinder.ClassInfo classInfo)
private void
linkParent(AbstractFinder.ClassInfo classInfo)
protected abstract java.lang.Class<?>
loadClass(java.lang.String fixedName)
protected void
readClassDef(java.io.InputStream in)
protected void
readClassDef(java.io.InputStream in, java.lang.String path)
protected void
readClassDef(java.lang.Class clazz)
protected void
readClassDef(java.lang.String className)
-
-
-
Field Detail
-
annotated
private final java.util.Map<java.lang.String,java.util.List<AbstractFinder.Info>> annotated
-
classInfos
protected final java.util.Map<java.lang.String,AbstractFinder.ClassInfo> classInfos
-
originalInfos
protected final java.util.Map<java.lang.String,AbstractFinder.ClassInfo> originalInfos
-
classesNotLoaded
private final java.util.List<java.lang.String> classesNotLoaded
-
ASM_FLAGS
private final int ASM_FLAGS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getResource
protected abstract java.net.URL getResource(java.lang.String className)
-
loadClass
protected abstract java.lang.Class<?> loadClass(java.lang.String fixedName) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
getAnnotatedClassNames
public java.util.List<java.lang.String> getAnnotatedClassNames()
- Specified by:
getAnnotatedClassNames
in interfaceIAnnotationFinder
-
link
public AbstractFinder link() throws java.io.IOException
The link() method must be called to successfully use the findSubclasses and findImplementations methods- Returns:
- Throws:
java.io.IOException
-
linkParent
private void linkParent(AbstractFinder.ClassInfo classInfo) throws java.io.IOException
- Throws:
java.io.IOException
-
linkInterfaces
private void linkInterfaces(AbstractFinder.ClassInfo classInfo) throws java.io.IOException
- Throws:
java.io.IOException
-
isAnnotationPresent
public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
isAnnotationPresent
in interfaceIAnnotationFinder
-
getClassesNotLoaded
public java.util.List<java.lang.String> getClassesNotLoaded()
Returns a list of classes that could not be loaded in last invoked findAnnotated* method. The list will only contain entries of classes whose byte code matched the requirements of last invoked find* method, but were unable to be loaded and included in the results. The list returned is unmodifiable. Once obtained, the returned list will be a live view of the results from the last findAnnotated* method call. This method is not thread safe.- Specified by:
getClassesNotLoaded
in interfaceIAnnotationFinder
- Returns:
- an unmodifiable live view of classes that could not be loaded in previous findAnnotated* call.
-
findAnnotatedPackages
public java.util.List<java.lang.Package> findAnnotatedPackages(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findAnnotatedPackages
in interfaceIAnnotationFinder
-
findAnnotatedClasses
public java.util.List<java.lang.Class<?>> findAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findAnnotatedClasses
in interfaceIAnnotationFinder
-
findMetaAnnotatedClasses
public java.util.List<Annotated<java.lang.Class<?>>> findMetaAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findMetaAnnotatedClasses
in interfaceIAnnotationFinder
-
findInheritedAnnotatedClasses
public java.util.List<java.lang.Class<?>> findInheritedAnnotatedClasses(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Naive implementation - works extremelly slow O(n^3)- Specified by:
findInheritedAnnotatedClasses
in interfaceIAnnotationFinder
- Parameters:
annotation
-- Returns:
- list of directly or indirectly (inherited) annotated classes
-
findAnnotatedMethods
public java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findAnnotatedMethods
in interfaceIAnnotationFinder
-
findMetaAnnotatedMethods
public java.util.List<Annotated<java.lang.reflect.Method>> findMetaAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findMetaAnnotatedMethods
in interfaceIAnnotationFinder
-
findAnnotatedConstructors
public java.util.List<java.lang.reflect.Constructor> findAnnotatedConstructors(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findAnnotatedConstructors
in interfaceIAnnotationFinder
-
findAnnotatedFields
public java.util.List<java.lang.reflect.Field> findAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findAnnotatedFields
in interfaceIAnnotationFinder
-
findMetaAnnotatedFields
public java.util.List<Annotated<java.lang.reflect.Field>> findMetaAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- Specified by:
findMetaAnnotatedFields
in interfaceIAnnotationFinder
-
findClassesInPackage
public java.util.List<java.lang.Class<?>> findClassesInPackage(java.lang.String packageName, boolean recursive)
- Specified by:
findClassesInPackage
in interfaceIAnnotationFinder
-
findSubclasses
public <T> java.util.List<java.lang.Class<? extends T>> findSubclasses(java.lang.Class<T> clazz)
- Specified by:
findSubclasses
in interfaceIAnnotationFinder
-
findSubclasses
private <T> void findSubclasses(AbstractFinder.ClassInfo classInfo, java.util.List<java.lang.Class<? extends T>> found, java.lang.Class<T> clazz)
-
_findSubclasses
private <T> java.util.List<java.lang.Class<? extends T>> _findSubclasses(java.lang.Class<T> clazz)
-
findImplementations
public <T> java.util.List<java.lang.Class<? extends T>> findImplementations(java.lang.Class<T> clazz)
- Specified by:
findImplementations
in interfaceIAnnotationFinder
-
collectImplementations
private java.util.List<AbstractFinder.ClassInfo> collectImplementations(java.lang.String interfaceName)
-
getAnnotationInfos
protected java.util.List<AbstractFinder.Info> getAnnotationInfos(java.lang.String name)
-
readClassDef
protected void readClassDef(java.lang.String className)
-
readClassDef
protected void readClassDef(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
readClassDef
protected void readClassDef(java.io.InputStream in, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
readClassDef
protected void readClassDef(java.lang.Class clazz)
-
-