AnnotationMatchingPointcut uses AnnotatedElementUtils.hasAnnotation
For consistency with AnnotationAsyncExecutionInterceptor (based on AnnotatedElementUtils.findMergedAnnotation) which is the main companion of AnnotationMatchingPointcut's checkInherited mode. Issue: SPR-16933
This commit is contained in:
parent
57ded51de0
commit
8f513f8561
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,7 +19,7 @@ package org.springframework.aop.support.annotation;
|
|||
import java.lang.annotation.Annotation;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ public class AnnotationClassFilter implements ClassFilter {
|
|||
* @param annotationType the annotation type to look for
|
||||
* @param checkInherited whether to also check the superclasses and
|
||||
* interfaces as well as meta-annotations for the annotation type
|
||||
* (i.e. whether to use {@link AnnotationUtils#findAnnotation(Class, Class)}
|
||||
* (i.e. whether to use {@link AnnotatedElementUtils#hasAnnotation}
|
||||
* semantics instead of standard Java {@link Class#isAnnotationPresent})
|
||||
*/
|
||||
public AnnotationClassFilter(Class<? extends Annotation> annotationType, boolean checkInherited) {
|
||||
|
@ -62,8 +62,7 @@ public class AnnotationClassFilter implements ClassFilter {
|
|||
|
||||
@Override
|
||||
public boolean matches(Class<?> clazz) {
|
||||
return (this.checkInherited ?
|
||||
(AnnotationUtils.findAnnotation(clazz, this.annotationType) != null) :
|
||||
return (this.checkInherited ? AnnotatedElementUtils.hasAnnotation(clazz, this.annotationType) :
|
||||
clazz.isAnnotationPresent(this.annotationType));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.lang.reflect.Proxy;
|
|||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.aop.support.StaticMethodMatcher;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
|
|||
* @param annotationType the annotation type to look for
|
||||
* @param checkInherited whether to also check the superclasses and
|
||||
* interfaces as well as meta-annotations for the annotation type
|
||||
* (i.e. whether to use {@link AnnotationUtils#findAnnotation(Method, Class)}
|
||||
* (i.e. whether to use {@link AnnotatedElementUtils#hasAnnotation}
|
||||
* semantics instead of standard Java {@link Method#isAnnotationPresent})
|
||||
* @since 5.0
|
||||
*/
|
||||
|
@ -81,8 +81,7 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
|
|||
}
|
||||
|
||||
private boolean matchesMethod(Method method) {
|
||||
return (this.checkInherited ?
|
||||
(AnnotationUtils.findAnnotation(method, this.annotationType) != null) :
|
||||
return (this.checkInherited ? AnnotatedElementUtils.hasAnnotation(method, this.annotationType) :
|
||||
method.isAnnotationPresent(this.annotationType));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue