ServiceActivatorEndpoint is now ServiceActivatingConsumer.

This commit is contained in:
Mark Fisher
2008-10-14 15:06:18 +00:00
parent 10fd9304f0
commit 5f6e6277cd
11 changed files with 85 additions and 85 deletions

View File

@@ -100,10 +100,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean
Annotation[] annotations = AnnotationUtils.getAnnotations(method);
for (Annotation annotation : annotations) {
MethodAnnotationPostProcessor postProcessor = postProcessors.get(annotation.annotationType());
if (postProcessor != null) {
if (!shouldCreateEndpoint(annotation)) {
continue;
}
if (postProcessor != null && shouldCreateEndpoint(annotation)) {
Object result = postProcessor.postProcess(bean, beanName, method, annotation);
if (result != null && result instanceof MessageEndpoint) {
String endpointBeanName = generateBeanName(beanName, method, annotation.annotationType());

View File

@@ -20,9 +20,8 @@ import java.lang.reflect.Method;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
import org.springframework.integration.endpoint.ServiceActivatingConsumer;
import org.springframework.integration.message.MessageConsumer;
import org.springframework.integration.message.MessageMappingMethodInvoker;
/**
* Post-processor for Methods annotated with {@link ServiceActivator @ServiceActivator}.
@@ -38,8 +37,7 @@ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnot
@Override
protected MessageConsumer createConsumer(Object bean, Method method, ServiceActivator annotation) {
MessageMappingMethodInvoker invoker = new MessageMappingMethodInvoker(bean, method);
return new ServiceActivatorEndpoint(invoker);
return new ServiceActivatingConsumer(bean, method);
}
}

View File

@@ -20,8 +20,9 @@ import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
import org.springframework.integration.message.MessageMappingMethodInvoker;
import org.springframework.integration.endpoint.ServiceActivatingConsumer;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Parser for the <service-activator> element.
@@ -32,9 +33,14 @@ public class ServiceActivatorParser extends AbstractConsumerEndpointParser {
@Override
protected BeanDefinitionBuilder parseConsumer(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ServiceActivatorEndpoint.class);
String constructorArg = this.parseAdapter(element, parserContext, MessageMappingMethodInvoker.class);
builder.addConstructorArgReference(constructorArg);
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ServiceActivatingConsumer.class);
String ref = element.getAttribute(REF_ATTRIBUTE);
Assert.hasText(ref, "The '" + REF_ATTRIBUTE + "' attribute is required.");
builder.addConstructorArgReference(ref);
if (StringUtils.hasText(element.getAttribute(METHOD_ATTRIBUTE))) {
String method = element.getAttribute(METHOD_ATTRIBUTE);
builder.addConstructorArgValue(method);
}
return builder;
}

View File

@@ -31,19 +31,14 @@ import org.springframework.util.Assert;
/**
* @author Mark Fisher
*/
public class ServiceActivatorEndpoint extends AbstractReplyProducingMessageConsumer implements InitializingBean {
public class ServiceActivatingConsumer extends AbstractReplyProducingMessageConsumer implements InitializingBean {
private final MethodResolver methodResolver = new DefaultMethodResolver(ServiceActivator.class);
private final MethodInvoker invoker;
public ServiceActivatorEndpoint(MethodInvoker invoker) {
Assert.notNull(invoker, "invoker must not be null");
this.invoker = invoker;
}
public ServiceActivatorEndpoint(final Object object) {
public ServiceActivatingConsumer(final Object object) {
Assert.notNull(object, "object must not be null");
Method method = this.methodResolver.findMethod(object);
Assert.notNull(method, "unable to resolve ServiceActivator method on target class ["
@@ -51,8 +46,12 @@ public class ServiceActivatorEndpoint extends AbstractReplyProducingMessageConsu
this.invoker = new MessageMappingMethodInvoker(object, method);
}
public ServiceActivatorEndpoint(Object object, String methodName) {
this(new MessageMappingMethodInvoker(object, methodName));
public ServiceActivatingConsumer(Object object, Method method) {
this.invoker = new MessageMappingMethodInvoker(object, method);
}
public ServiceActivatingConsumer(Object object, String methodName) {
this.invoker = new MessageMappingMethodInvoker(object, methodName);
}
@@ -74,7 +73,7 @@ public class ServiceActivatorEndpoint extends AbstractReplyProducingMessageConsu
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new MessageHandlingException(message, "failure occurred in endpoint '" + this + "'", e);
throw new MessageHandlingException(message, "failure occurred in Service Activator '" + this + "'", e);
}
}