Moved the 'outputChannel' property from AbstractEndpoint to AbstractInOutEndpoint.
This commit is contained in:
@@ -81,10 +81,10 @@ public class ChannelAdapterParser extends AbstractBeanDefinitionParser {
|
||||
adapterBuilder.addPropertyReference("source", source);
|
||||
}
|
||||
if (StringUtils.hasText(channelName)) {
|
||||
adapterBuilder.addPropertyReference("outputChannel", channelName);
|
||||
adapterBuilder.addPropertyReference("channel", channelName);
|
||||
}
|
||||
else {
|
||||
adapterBuilder.addPropertyReference("outputChannel", this.createDirectChannel(element, parserContext));
|
||||
adapterBuilder.addPropertyReference("channel", this.createDirectChannel(element, parserContext));
|
||||
}
|
||||
}
|
||||
else if (StringUtils.hasText(target)) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.dispatcher.PollingDispatcher;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.AbstractInOutEndpoint;
|
||||
import org.springframework.integration.scheduling.PollingSchedule;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -102,13 +103,15 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
else {
|
||||
endpoint.setSource(inputChannel);
|
||||
}
|
||||
String outputChannelName = (String) AnnotationUtils.getValue(annotation, OUTPUT_CHANNEL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
MessageChannel outputChannel = this.messageBus.lookupChannel(outputChannelName);
|
||||
if (outputChannel == null) {
|
||||
throw new ConfigurationException("unable to resolve outputChannel '" + outputChannelName + "'");
|
||||
if (endpoint instanceof AbstractInOutEndpoint) {
|
||||
String outputChannelName = (String) AnnotationUtils.getValue(annotation, OUTPUT_CHANNEL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
MessageChannel outputChannel = this.messageBus.lookupChannel(outputChannelName);
|
||||
if (outputChannel == null) {
|
||||
throw new ConfigurationException("unable to resolve outputChannel '" + outputChannelName + "'");
|
||||
}
|
||||
((AbstractInOutEndpoint) endpoint).setOutputChannel(outputChannel);
|
||||
}
|
||||
endpoint.setOutputChannel(outputChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ChannelAdapterAnnotationPostProcessor implements MethodAnnotationPo
|
||||
PollingDispatcher poller = this.createPoller(source, pollerAnnotation);
|
||||
InboundChannelAdapter adapter = new InboundChannelAdapter();
|
||||
adapter.setSource(poller);
|
||||
adapter.setOutputChannel(channel);
|
||||
adapter.setChannel(channel);
|
||||
adapter.setBeanName(this.generateUniqueName(channel.getName() + ".inboundAdapter"));
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.integration.channel.ChannelRegistry;
|
||||
import org.springframework.integration.channel.ChannelRegistryAware;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageExchangeTemplate;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
@@ -43,8 +42,6 @@ public abstract class AbstractEndpoint implements MessageEndpoint, ChannelRegist
|
||||
|
||||
private MessageSource<?> source;
|
||||
|
||||
private MessageChannel outputChannel;
|
||||
|
||||
private volatile ErrorHandler errorHandler;
|
||||
|
||||
private volatile ChannelRegistry channelRegistry;
|
||||
@@ -71,14 +68,6 @@ public abstract class AbstractEndpoint implements MessageEndpoint, ChannelRegist
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public MessageChannel getOutputChannel() {
|
||||
return this.outputChannel;
|
||||
}
|
||||
|
||||
public void setOutputChannel(MessageChannel outputChannel) {
|
||||
this.outputChannel = outputChannel;
|
||||
}
|
||||
|
||||
protected ChannelRegistry getChannelRegistry() {
|
||||
return this.channelRegistry;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.springframework.integration.message.selector.MessageSelector;
|
||||
*/
|
||||
public abstract class AbstractInOutEndpoint extends AbstractEndpoint {
|
||||
|
||||
private MessageChannel outputChannel;
|
||||
|
||||
private volatile MessageSelector selector;
|
||||
|
||||
private volatile boolean requiresReply = false;
|
||||
@@ -43,6 +45,14 @@ public abstract class AbstractInOutEndpoint extends AbstractEndpoint {
|
||||
private final List<EndpointInterceptor> interceptors = new CopyOnWriteArrayList<EndpointInterceptor>();
|
||||
|
||||
|
||||
public void setOutputChannel(MessageChannel outputChannel) {
|
||||
this.outputChannel = outputChannel;
|
||||
}
|
||||
|
||||
public MessageChannel getOutputChannel() {
|
||||
return this.outputChannel;
|
||||
}
|
||||
|
||||
public void setSelector(MessageSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,20 @@ import org.springframework.integration.message.MessagingException;
|
||||
*/
|
||||
public class InboundChannelAdapter extends AbstractEndpoint {
|
||||
|
||||
private MessageChannel channel;
|
||||
|
||||
|
||||
public void setChannel(MessageChannel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean sendInternal(Message<?> message) {
|
||||
if (this.channel == null) {
|
||||
throw new MessageDeliveryException(message, "no channel has been provided");
|
||||
}
|
||||
try {
|
||||
boolean sent = this.getMessageExchangeTemplate().send(message, this.getOutputChannel());
|
||||
boolean sent = this.getMessageExchangeTemplate().send(message, this.channel);
|
||||
if (sent && this.getSource() instanceof MessageDeliveryAware) {
|
||||
((MessageDeliveryAware) this.getSource()).onSend(message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user