From 99f101e45308c480f05f6aeafc03a30e95fe2961 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Fri, 5 Sep 2008 17:35:19 +0000 Subject: [PATCH] Moved the 'outputChannel' property from AbstractEndpoint to AbstractInOutEndpoint. --- .../integration/config/ChannelAdapterParser.java | 4 ++-- .../AbstractMethodAnnotationPostProcessor.java | 15 +++++++++------ .../ChannelAdapterAnnotationPostProcessor.java | 2 +- .../integration/endpoint/AbstractEndpoint.java | 11 ----------- .../endpoint/AbstractInOutEndpoint.java | 10 ++++++++++ .../endpoint/InboundChannelAdapter.java | 12 +++++++++++- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/ChannelAdapterParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/ChannelAdapterParser.java index 75bf1492f6..2334e23b44 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/ChannelAdapterParser.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/ChannelAdapterParser.java @@ -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)) { diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java index 86e5cab52d..2137d22346 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java @@ -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 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; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractInOutEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractInOutEndpoint.java index 014b233ded..b0e2672c7d 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractInOutEndpoint.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/AbstractInOutEndpoint.java @@ -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 interceptors = new CopyOnWriteArrayList(); + public void setOutputChannel(MessageChannel outputChannel) { + this.outputChannel = outputChannel; + } + + public MessageChannel getOutputChannel() { + return this.outputChannel; + } + public void setSelector(MessageSelector selector) { this.selector = selector; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/InboundChannelAdapter.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/InboundChannelAdapter.java index 995d9465cd..738a9f1a8b 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/InboundChannelAdapter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/InboundChannelAdapter.java @@ -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); }