|
@@ -21,11 +21,12 @@ import org.aspectj.lang.JoinPoint;
|
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
|
import org.springframework.util.ClassUtils;
|
|
|
+import org.springframework.util.ReflectionUtils;
|
|
|
|
|
|
import java.lang.annotation.Annotation;
|
|
|
import java.lang.reflect.Method;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
public final class AopUtils {
|
|
|
|
|
@@ -40,6 +41,33 @@ public final class AopUtils {
|
|
|
}
|
|
|
m = ClassUtils.getMostSpecificMethod(m, targetClass);
|
|
|
a = AnnotationUtils.findAnnotation(m, annClass);
|
|
|
+ if (a == null) {
|
|
|
+ List<Class> supers = new ArrayList<>();
|
|
|
+ supers.addAll(Arrays.asList(targetClass.getInterfaces()));
|
|
|
+ if (targetClass.getSuperclass() != Object.class) {
|
|
|
+ supers.add(targetClass.getSuperclass());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Class aClass : supers) {
|
|
|
+ if(aClass==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Method ims[] = new Method[1];
|
|
|
+
|
|
|
+ ReflectionUtils.doWithMethods(aClass, im -> {
|
|
|
+ if (im.getName().equals(method.getName()) && im.getParameterCount() == method.getParameterCount()) {
|
|
|
+ ims[0] = im;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (ims[0] != null) {
|
|
|
+ a = findMethodAnnotation(aClass, ims[0], annClass);
|
|
|
+ if (a != null) {
|
|
|
+ return a;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return a;
|
|
|
}
|
|
|
|