This commit is contained in:
Arjen Poutsma
2008-07-18 11:48:15 +00:00
parent 57e49441af
commit eaba5accd6
2 changed files with 24 additions and 25 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}