Moved 'outputChannel' configuration into each implementation instead of AbstractMethodAnnotationPostProcessor.
This commit is contained in:
@@ -34,7 +34,6 @@ import org.springframework.integration.endpoint.MessageEndpoint;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageProducer;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -47,8 +46,6 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
|
||||
private static final String INPUT_CHANNEL_ATTRIBUTE = "inputChannel";
|
||||
|
||||
private static final String OUTPUT_CHANNEL_ATTRIBUTE = "outputChannel";
|
||||
|
||||
|
||||
protected final GenericBeanFactoryAccessor beanFactoryAccessor;
|
||||
|
||||
@@ -108,14 +105,6 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
else {
|
||||
throw new IllegalArgumentException("unsupported channel type: [" + inputChannel.getClass() + "]");
|
||||
}
|
||||
if (consumer instanceof MessageProducer) {
|
||||
String outputChannelName = (String) AnnotationUtils.getValue(annotation, OUTPUT_CHANNEL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
MessageChannel outputChannel = this.channelResolver.resolveChannelName(outputChannelName);
|
||||
Assert.notNull(outputChannel, "unable to resolve outputChannel '" + outputChannelName + "'");
|
||||
((MessageProducer) consumer).setOutputChannel(outputChannel);
|
||||
}
|
||||
}
|
||||
if (consumer instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) consumer).setBeanFactory(this.beanFactoryAccessor.getBeanFactory());
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ public class AggregatorAnnotationPostProcessor extends AbstractMethodAnnotationP
|
||||
Assert.notNull(discardChannel, "failed to resolve discardChannel '" + discardChannelName + "'");
|
||||
aggregator.setDiscardChannel(discardChannel);
|
||||
}
|
||||
String outputChannelName = annotation.outputChannel();
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
aggregator.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
|
||||
}
|
||||
aggregator.setSendTimeout(annotation.sendTimeout());
|
||||
aggregator.setSendPartialResultOnTimeout(annotation.sendPartialResultsOnTimeout());
|
||||
aggregator.setReaperInterval(annotation.reaperInterval());
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Post-processor for Methods annotated with {@link ServiceActivator @ServiceActivator}.
|
||||
@@ -37,7 +38,12 @@ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnot
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, ServiceActivator annotation) {
|
||||
return new ServiceActivatingConsumer(bean, method);
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(bean, method);
|
||||
String outputChannelName = annotation.outputChannel();
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
serviceActivator.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
|
||||
}
|
||||
return serviceActivator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.splitter.MethodInvokingSplitter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Post-processor for Methods annotated with {@link Splitter @Splitter}.
|
||||
@@ -37,7 +38,12 @@ public class SplitterAnnotationPostProcessor extends AbstractMethodAnnotationPos
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, Splitter annotation) {
|
||||
return new MethodInvokingSplitter(bean, method);
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(bean, method);
|
||||
String outputChannelName = annotation.outputChannel();
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
splitter.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
|
||||
}
|
||||
return splitter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.transformer.MethodInvokingTransformer;
|
||||
import org.springframework.integration.transformer.MessageTransformingConsumer;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Post-processor for Methods annotated with {@link Transformer @Transformer}.
|
||||
@@ -39,7 +40,12 @@ public class TransformerAnnotationPostProcessor extends AbstractMethodAnnotation
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, Transformer annotation) {
|
||||
MethodInvokingTransformer transformer = new MethodInvokingTransformer(bean, method);
|
||||
return new MessageTransformingConsumer(transformer);
|
||||
MessageTransformingConsumer consumer = new MessageTransformingConsumer(transformer);
|
||||
String outputChannelName = annotation.outputChannel();
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
consumer.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
|
||||
}
|
||||
return consumer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user