I'm trying to find methods in a Spring RestController that are annotated with a given annotation. In order to see what annotations exist on methods for that RestController, I've done the following:
Map<String, Object> beans = appContext.getBeansWithAnnotation(RestController.class);
for (Map.Entry<String, Object> entry : beans.entrySet()) {
Method[] allMethods = entry.getValue().getClass().getDeclaredMethods();
for(Method method : allMethods) {
LOG.debug("Method: " + method.getName());
Annotation[] annotations = method.getDeclaredAnnotations();
for(Annotation annotation : annotations) {
LOG.debug("Annotation: " + annotation);
}
}
}
The problem is that I'm not seeing any annotations at all, despite the fact that I know I have at least one that is annotated with @Retention(RetentionPolicy.RUNTIME)
. Any ideas? Is CGLIB a factor here? (Being a Controller, the methods in question are bieing proxied using CGBLIB).
Aucun commentaire:
Enregistrer un commentaire