From eaba5accd62366daf7f62e8975dcbc165e41fe0f Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Fri, 18 Jul 2008 11:48:15 +0000 Subject: [PATCH] SWS-396 --- ...stractAnnotationMethodEndpointMapping.java | 4 +- .../AbstractMethodEndpointMapping.java | 45 +++++++++---------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/core-tiger/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java b/core-tiger/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java index 7179046e..9a8a4fb8 100644 --- a/core-tiger/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java +++ b/core-tiger/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractAnnotationMethodEndpointMapping.java @@ -20,6 +20,7 @@ import java.lang.annotation.Annotation; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; +import org.springframework.core.annotation.AnnotationUtils; import org.springframework.ws.server.endpoint.annotation.Endpoint; /** @@ -65,7 +66,8 @@ public abstract class AbstractAnnotationMethodEndpointMapping extends AbstractMe for (int i = 0; i < beanNames.length; i++) { String beanName = beanNames[i]; Class endpointClass = getApplicationContext().getType(beanName); - if (endpointClass != null && endpointClass.getAnnotation(getEndpointAnnotationType()) != null) { + if (endpointClass != null && + AnnotationUtils.findAnnotation(endpointClass, getEndpointAnnotationType()) != null) { registerMethods(beanName); } } diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java b/core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java index 5bc5166c..8f272e85 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/mapping/AbstractMethodEndpointMapping.java @@ -23,9 +23,9 @@ import java.util.Map; import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContextException; -import org.springframework.core.JdkVersion; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; +import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.MethodEndpoint; @@ -109,19 +109,18 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointMapp * * @see #getLookupKeyForMethod(Method) */ - protected void registerMethods(Object endpoint) { + protected void registerMethods(final Object endpoint) { Assert.notNull(endpoint, "'endpoint' must not be null"); - Method[] methods = getEndpointClass(endpoint).getMethods(); - for (int i = 0; i < methods.length; i++) { - if (JdkVersion.isAtLeastJava15() && methods[i].isSynthetic() || - methods[i].getDeclaringClass().equals(Object.class)) { - continue; + Class endpointClass = getEndpointClass(endpoint); + ReflectionUtils.doWithMethods(endpointClass, new ReflectionUtils.MethodCallback() { + + public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { + String key = getLookupKeyForMethod(method); + if (StringUtils.hasLength(key)) { + registerEndpoint(key, new MethodEndpoint(endpoint, method)); + } } - String key = getLookupKeyForMethod(methods[i]); - if (StringUtils.hasLength(key)) { - registerEndpoint(key, new MethodEndpoint(endpoint, methods[i])); - } - } + }); } /** @@ -131,20 +130,19 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointMapp * * @see #getLookupKeyForMethod(Method) */ - protected void registerMethods(String beanName) { + protected void registerMethods(final String beanName) { Assert.hasText(beanName, "'beanName' must not be empty"); Class endpointClass = getApplicationContext().getType(beanName); - Method[] methods = endpointClass.getMethods(); - for (int i = 0; i < methods.length; i++) { - if (JdkVersion.isAtLeastJava15() && methods[i].isSynthetic() || - methods[i].getDeclaringClass().equals(Object.class)) { - continue; + ReflectionUtils.doWithMethods(endpointClass, new ReflectionUtils.MethodCallback() { + + public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { + String key = getLookupKeyForMethod(method); + if (StringUtils.hasLength(key)) { + registerEndpoint(key, new MethodEndpoint(beanName, getApplicationContext(), method)); + } } - String key = getLookupKeyForMethod(methods[i]); - if (StringUtils.hasLength(key)) { - registerEndpoint(key, new MethodEndpoint(beanName, getApplicationContext(), methods[i])); - } - } + + }); } /** @@ -175,5 +173,4 @@ public abstract class AbstractMethodEndpointMapping extends AbstractEndpointMapp } return AopUtils.getTargetClass(endpoint); } - }