AnnotationUtils.getAnnotation generally supports meta-annotation lookup

This commit is contained in:
Juergen Hoeller 2009-07-21 14:35:42 +00:00
parent ec1f0e6211
commit dbdd6eca60
1 changed files with 11 additions and 1 deletions

View File

@ -75,7 +75,17 @@ public abstract class AnnotationUtils {
* @see org.springframework.core.BridgeMethodResolver#findBridgedMethod(Method) * @see org.springframework.core.BridgeMethodResolver#findBridgedMethod(Method)
*/ */
public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) { public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
return BridgeMethodResolver.findBridgedMethod(method).getAnnotation(annotationType); Method resolvedMethod = BridgeMethodResolver.findBridgedMethod(method);
A ann = resolvedMethod.getAnnotation(annotationType);
if (ann == null) {
for (Annotation metaAnn : resolvedMethod.getAnnotations()) {
ann = metaAnn.annotationType().getAnnotation(annotationType);
if (ann != null) {
break;
}
}
}
return ann;
} }
/** /**