use of org.reflections.scanners.MethodAnnotationsScanner in project motech by motech.
the class ReflectionsUtil method getMethods.
/**
* Looks for methods annotated with the given annotation.
*
* @param annotation an annotation to look for.
* @param bundle a bundle to look in.
* @return a list of moethods, annotated with the given annotation
*/
public static Set<Method> getMethods(Class<? extends Annotation> annotation, Bundle bundle) {
LOGGER.debug("Searching for methods with annotations: {}", annotation.getName());
Reflections reflections = configureReflection(bundle, new WrappedBundleClassLoader(bundle), new MethodAnnotationsScanner());
Set<Method> methods = reflections.getMethodsAnnotatedWith(annotation);
LOGGER.debug("Searched for methods with annotations: {}", annotation.getName());
LOGGER.trace("Found {} methods with annotations: {}", methods.size(), annotation.getName());
return methods;
}
use of org.reflections.scanners.MethodAnnotationsScanner in project serenity-jbehave by serenity-bdd.
the class ClassFinder method annotatedClassesInPackage.
public List<Class<?>> annotatedClassesInPackage(String packageName) {
Reflections reflections = new Reflections(packageName, new SubTypesScanner(), new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new ResourcesScanner(), getClassLoader());
Set<Class<?>> matchingClasses = new HashSet<>();
for (Class<? extends Annotation> expectedAnnotation : expectedAnnotations) {
matchingClasses.addAll(reflections.getTypesAnnotatedWith(expectedAnnotation));
matchingClasses.addAll(classesFrom(reflections.getMethodsAnnotatedWith(expectedAnnotation)));
}
return ImmutableList.copyOf(matchingClasses);
}
Aggregations