public List findAnnotatedMethods()

in xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java [667:706]


    public List<Method> findAnnotatedMethods(Class<? extends Annotation> annotation) {
        classesNotLoaded.clear();
        List<ClassInfo> seen = new LinkedList<ClassInfo>();
        List<Method> methods = new LinkedList<Method>();
        List<Info> infos = getAnnotationInfos(annotation.getName());
        for (Info info : infos) {
            if (info instanceof MethodInfo && !info.getName().equals("<init>")) {
                final MethodInfo methodInfo = (MethodInfo) info;

                if (checkRuntimeAnnotation) {
                    final ClassInfo classInfo = methodInfo.getDeclaringClass();

                    if (seen.contains(classInfo)) continue;

                    seen.add(classInfo);

                    try {
                        Class clazz = classInfo.get();
                        for (Method method : clazz.getDeclaredMethods()) {
                            if (method.isAnnotationPresent(annotation)) {
                                methods.add(method);
                            }
                        }
                    } catch (ClassNotFoundException | NoClassDefFoundError e) {
                        classesNotLoaded.add(classInfo.getName());
                    } catch (ClassCircularityError cce) {
                        classesNotLoaded.add(classInfo.getName());
                    }
                } else {
                    try {
                        final Method method = (Method) methodInfo.get();
                        methods.add(method);
                    } catch (ClassNotFoundException | NoClassDefFoundError e) {
                        classesNotLoaded.add(methodInfo.getDeclaringClass().getName());
                    }
                }
            }
        }
        return methods;
    }