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 TypeClassDescriptionclassclassclassclassstatic interfaceclassclassclassclassclass -
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 booleanfindAnnotatedClasses(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.booleanprotected List<AnnotationFinder.Info> initAnnotationInfos(String name) booleanisAnnotationPresent(Class<? extends Annotation> annotation) protected booleanprotected booleanlink()The link() method must be called to successfully use the findSubclasses and findImplementations methodsprotected voidlinkInterfaces(AnnotationFinder.ClassInfo classInfo) protected voidlinkParent(AnnotationFinder.ClassInfo classInfo) protected Map<String, List<AnnotationFinder.Info>> protected Map<String, AnnotationFinder.ClassInfo> protected voidreadClassDef(Class clazz) protected voidreadClassDef(String className) protected voidreadClassDef(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:
getAnnotatedClassNamesin 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:
isAnnotationPresentin 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:
getClassesNotLoadedin interfaceIAnnotationFinder- Returns:
- an unmodifiable live view of classes that could not be loaded in previous findAnnotated* call.
-
findAnnotatedPackages
- Specified by:
findAnnotatedPackagesin interfaceIAnnotationFinder
-
findAnnotatedClasses
- Specified by:
findAnnotatedClassesin interfaceIAnnotationFinder
-
findMetaAnnotatedClasses
- Specified by:
findMetaAnnotatedClassesin interfaceIAnnotationFinder
-
findInheritedAnnotatedClasses
Naive implementation - works extremelly slow O(n^3)- Specified by:
findInheritedAnnotatedClassesin interfaceIAnnotationFinder- Parameters:
annotation-- Returns:
- list of directly or indirectly (inherited) annotated classes
-
findAnnotatedMethods
- Specified by:
findAnnotatedMethodsin interfaceIAnnotationFinder
-
findAnnotatedMethodParameters
public List<Parameter<Method>> findAnnotatedMethodParameters(Class<? extends Annotation> annotation) -
findMetaAnnotatedMethods
- Specified by:
findMetaAnnotatedMethodsin interfaceIAnnotationFinder
-
findMetaAnnotatedFields
- Specified by:
findMetaAnnotatedFieldsin interfaceIAnnotationFinder
-
findAnnotatedConstructors
- Specified by:
findAnnotatedConstructorsin interfaceIAnnotationFinder
-
findAnnotatedConstructorParameters
public List<Parameter<Constructor<?>>> findAnnotatedConstructorParameters(Class<? extends Annotation> annotation) -
findAnnotatedFields
- Specified by:
findAnnotatedFieldsin interfaceIAnnotationFinder
-
findClassesInPackage
- Specified by:
findClassesInPackagein interfaceIAnnotationFinder
-
findSubclasses
- Specified by:
findSubclassesin interfaceIAnnotationFinder
-
findImplementations
- Specified by:
findImplementationsin interfaceIAnnotationFinder
-
getAnnotationInfos
-
initAnnotationInfos
-
readClassDef
-
readClassDef
- Throws:
IOException
-
readClassDef
-
select
-
select
-
select
-