AnnotationUtils.getAnnotation generally supports meta-annotation lookup

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1581 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller 2009-07-21 14:35:42 +00:00
parent 89c0218430
commit cf52e525ae
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)
*/
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;
}
/**