|
21 | 21 | import java.util.List;
|
22 | 22 | import java.util.concurrent.atomic.AtomicReference;
|
23 | 23 |
|
24 |
| -import org.springframework.aop.support.AopUtils; |
| 24 | +import org.springframework.aop.framework.AopProxyUtils; |
25 | 25 | import org.springframework.core.annotation.AnnotatedElementUtils;
|
26 | 26 | import org.springframework.core.annotation.AnnotationUtils;
|
27 | 27 | import org.springframework.integration.annotation.EndpointId;
|
|
30 | 30 | import org.springframework.messaging.handler.annotation.Header;
|
31 | 31 | import org.springframework.messaging.handler.annotation.Headers;
|
32 | 32 | import org.springframework.messaging.handler.annotation.Payload;
|
33 |
| -import org.springframework.util.ClassUtils; |
34 | 33 | import org.springframework.util.ReflectionUtils;
|
35 | 34 | import org.springframework.util.StringUtils;
|
36 | 35 |
|
|
42 | 41 | * @author Gunnar Hillert
|
43 | 42 | * @author Soby Chacko
|
44 | 43 | * @author Artem Bilan
|
| 44 | + * |
45 | 45 | * @since 4.0
|
46 | 46 | */
|
47 | 47 | public final class MessagingAnnotationUtils {
|
@@ -77,9 +77,9 @@ public static boolean hasValue(Object value) {
|
77 | 77 | }
|
78 | 78 |
|
79 | 79 | public static Method findAnnotatedMethod(Object target, final Class<? extends Annotation> annotationType) {
|
80 |
| - final AtomicReference<Method> reference = new AtomicReference<Method>(); |
| 80 | + final AtomicReference<Method> reference = new AtomicReference<>(); |
81 | 81 |
|
82 |
| - ReflectionUtils.doWithMethods(getTargetClass(target), |
| 82 | + ReflectionUtils.doWithMethods(AopProxyUtils.ultimateTargetClass(target), |
83 | 83 | method -> reference.compareAndSet(null, method),
|
84 | 84 | method -> ReflectionUtils.USER_DECLARED_METHODS.matches(method) &&
|
85 | 85 | AnnotatedElementUtils.isAnnotated(method, annotationType.getName()));
|
@@ -129,20 +129,7 @@ public static String endpointIdValue(Method method) {
|
129 | 129 | return endpointId != null ? endpointId.value() : null;
|
130 | 130 | }
|
131 | 131 |
|
132 |
| - private static Class<?> getTargetClass(Object targetObject) { |
133 |
| - Class<?> targetClass = targetObject.getClass(); |
134 |
| - if (AopUtils.isAopProxy(targetObject)) { |
135 |
| - targetClass = AopUtils.getTargetClass(targetObject); |
136 |
| - } |
137 |
| - else if (ClassUtils.isCglibProxyClass(targetClass)) { |
138 |
| - Class<?> superClass = targetObject.getClass().getSuperclass(); |
139 |
| - if (!Object.class.equals(superClass)) { |
140 |
| - targetClass = superClass; |
141 |
| - } |
142 |
| - } |
143 |
| - return targetClass; |
| 132 | + private MessagingAnnotationUtils() { |
144 | 133 | }
|
145 | 134 |
|
146 |
| - private MessagingAnnotationUtils() { } |
147 |
| - |
148 | 135 | }
|
0 commit comments