Package org.apache.xbean.finder
Class AnnotationFinder
java.lang.Object
org.apache.xbean.finder.AnnotationFinder
- All Implemented Interfaces:
IAnnotationFinder
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.
- Version:
- $Rev: 1881759 $ $Date: 2020-09-16 10:29:43 +0200 (Wed, 16 Sep 2020) $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
class
class
class
static interface
class
class
class
class
class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String,
List<AnnotationFinder.Info>> protected final Map<String,
AnnotationFinder.ClassInfo> protected final Map<String,
AnnotationFinder.ClassInfo> -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationFinder
(Archive archive) AnnotationFinder
(Archive archive, boolean checkRuntimeAnnotation) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
findAnnotatedClasses
(Class<? extends Annotation> annotation) List<Parameter<Constructor<?>>>
findAnnotatedConstructorParameters
(Class<? extends Annotation> annotation) findAnnotatedConstructors
(Class<? extends Annotation> annotation) findAnnotatedFields
(Class<? extends Annotation> annotation) findAnnotatedMethodParameters
(Class<? extends Annotation> annotation) findAnnotatedMethods
(Class<? extends Annotation> annotation) findAnnotatedPackages
(Class<? extends Annotation> annotation) findClassesInPackage
(String packageName, boolean recursive) findImplementations
(Class<T> clazz) findInheritedAnnotatedClasses
(Class<? extends Annotation> annotation) Naive implementation - works extremelly slow O(n^3)findMetaAnnotatedClasses
(Class<? extends Annotation> annotation) findMetaAnnotatedFields
(Class<? extends Annotation> annotation) findMetaAnnotatedMethods
(Class<? extends Annotation> annotation) findSubclasses
(Class<T> clazz) protected List<AnnotationFinder.Info>
getAnnotationInfos
(String name) Returns a list of classes that could not be loaded in last invoked findAnnotated* method.boolean
protected List<AnnotationFinder.Info>
initAnnotationInfos
(String name) boolean
isAnnotationPresent
(Class<? extends Annotation> annotation) protected boolean
protected boolean
link()
The link() method must be called to successfully use the findSubclasses and findImplementations methodsprotected void
linkInterfaces
(AnnotationFinder.ClassInfo classInfo) protected void
linkParent
(AnnotationFinder.ClassInfo classInfo) protected Map<String,
List<AnnotationFinder.Info>> protected Map<String,
AnnotationFinder.ClassInfo> protected void
readClassDef
(Class clazz) protected void
readClassDef
(String className) protected void
readClassDef
(String className, InputStream in)
-
Field Details
-
annotated
-
classInfos
-
originalInfos
-
-
Constructor Details
-
AnnotationFinder
- Parameters:
archive
-checkRuntimeAnnotation
- Has no effect on findMetaAnnotated* methods
-
AnnotationFinder
-
-
Method Details
-
newAnnotatedMap
-
newClassInfoMap
-
cleanOnNaked
-
isTracked
-
hasMetaAnnotations
-
getAnnotatedClassNames
- Specified by:
getAnnotatedClassNames
in interfaceIAnnotationFinder
-
getArchive
-
link
The link() method must be called to successfully use the findSubclasses and findImplementations methods- Returns:
- Throws:
IOException
-
enableMetaAnnotations
-
enableFindImplementations
-
enableFindSubclasses
-
linkParent
-
isJvm
-
linkInterfaces
-
isAnnotationPresent
- Specified by:
isAnnotationPresent
in interfaceIAnnotationFinder
-
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
- Specified by:
findAnnotatedPackages
in interfaceIAnnotationFinder
-
findAnnotatedClasses
- Specified by:
findAnnotatedClasses
in interfaceIAnnotationFinder
-
findMetaAnnotatedClasses
- Specified by:
findMetaAnnotatedClasses
in interfaceIAnnotationFinder
-
findInheritedAnnotatedClasses
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
- Specified by:
findAnnotatedMethods
in interfaceIAnnotationFinder
-
findAnnotatedMethodParameters
public List<Parameter<Method>> findAnnotatedMethodParameters(Class<? extends Annotation> annotation) -
findMetaAnnotatedMethods
- Specified by:
findMetaAnnotatedMethods
in interfaceIAnnotationFinder
-
findMetaAnnotatedFields
- Specified by:
findMetaAnnotatedFields
in interfaceIAnnotationFinder
-
findAnnotatedConstructors
- Specified by:
findAnnotatedConstructors
in interfaceIAnnotationFinder
-
findAnnotatedConstructorParameters
public List<Parameter<Constructor<?>>> findAnnotatedConstructorParameters(Class<? extends Annotation> annotation) -
findAnnotatedFields
- Specified by:
findAnnotatedFields
in interfaceIAnnotationFinder
-
findClassesInPackage
- Specified by:
findClassesInPackage
in interfaceIAnnotationFinder
-
findSubclasses
- Specified by:
findSubclasses
in interfaceIAnnotationFinder
-
findImplementations
- Specified by:
findImplementations
in interfaceIAnnotationFinder
-
getAnnotationInfos
-
initAnnotationInfos
-
readClassDef
-
readClassDef
- Throws:
IOException
-
readClassDef
-
select
-
select
-
select
-