Moved channelRegistry property to AbstractEndpoint superclass instead of DefaultEndpoint, and removed the 'returnAddressOverrides' property as well as the corresponding XML attribute.
This commit is contained in:
@@ -48,8 +48,6 @@ public abstract class AbstractMessageEndpointParser extends AbstractSingleBeanDe
|
||||
|
||||
protected static final String OUTPUT_CHANNEL_ATTRIBUTE = "output-channel";
|
||||
|
||||
protected static final String RETURN_ADDRESS_OVERRIDES_ATTRIBUTE = "return-address-overrides";
|
||||
|
||||
private static final String POLLER_ELEMENT = "poller";
|
||||
|
||||
private static final String SELECTOR_ATTRIBUTE = "selector";
|
||||
@@ -114,9 +112,6 @@ public abstract class AbstractMessageEndpointParser extends AbstractSingleBeanDe
|
||||
builder, element, OUTPUT_CHANNEL_ATTRIBUTE, "outputChannelName");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, SELECTOR_ATTRIBUTE);
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, ERROR_HANDLER_ATTRIBUTE);
|
||||
String returnAddressOverridesAttribute = element.getAttribute(RETURN_ADDRESS_OVERRIDES_ATTRIBUTE);
|
||||
boolean returnAddressOverrides = "true".equals(returnAddressOverridesAttribute);
|
||||
builder.addPropertyValue("returnAddressOverrides", returnAddressOverrides);
|
||||
this.postProcessEndpointBean(builder, element, parserContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,6 @@
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="inputHandlerEndpointType">
|
||||
<xsd:attribute name="output-channel" type="xsd:string"/>
|
||||
<xsd:attribute name="return-address-overrides" type="xsd:boolean" default="false"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
@@ -20,6 +20,8 @@ import org.apache.commons.logging.Log;
|
||||
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.message.Message;
|
||||
import org.springframework.integration.message.MessageExchangeTemplate;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
@@ -34,7 +36,7 @@ import org.springframework.integration.util.ErrorHandler;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractEndpoint implements MessageEndpoint, BeanNameAware {
|
||||
public abstract class AbstractEndpoint implements MessageEndpoint, ChannelRegistryAware, BeanNameAware {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -48,6 +50,8 @@ public abstract class AbstractEndpoint implements MessageEndpoint, BeanNameAware
|
||||
|
||||
private volatile ErrorHandler errorHandler;
|
||||
|
||||
private volatile ChannelRegistry channelRegistry;
|
||||
|
||||
private final MessageExchangeTemplate messageExchangeTemplate = new MessageExchangeTemplate();
|
||||
|
||||
|
||||
@@ -86,6 +90,14 @@ public abstract class AbstractEndpoint implements MessageEndpoint, BeanNameAware
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
protected ChannelRegistry getChannelRegistry() {
|
||||
return this.channelRegistry;
|
||||
}
|
||||
|
||||
public void setChannelRegistry(ChannelRegistry channelRegistry) {
|
||||
this.channelRegistry = channelRegistry;
|
||||
}
|
||||
|
||||
protected MessageExchangeTemplate getMessageExchangeTemplate() {
|
||||
return this.messageExchangeTemplate;
|
||||
}
|
||||
|
||||
@@ -57,12 +57,10 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class DefaultEndpoint<T extends MessageHandler> extends AbstractRequestReplyEndpoint implements ChannelRegistryAware {
|
||||
public class DefaultEndpoint<T extends MessageHandler> extends AbstractRequestReplyEndpoint {
|
||||
|
||||
private final T handler;
|
||||
|
||||
private volatile ChannelRegistry channelRegistry;
|
||||
|
||||
private volatile MessageSelector selector;
|
||||
|
||||
private final List<EndpointInterceptor> interceptors = new ArrayList<EndpointInterceptor>();
|
||||
@@ -76,10 +74,19 @@ public class DefaultEndpoint<T extends MessageHandler> extends AbstractRequestRe
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
protected T getHandler() {
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChannelRegistry(ChannelRegistry channelRegistry) {
|
||||
super.setChannelRegistry(channelRegistry);
|
||||
if (this.handler instanceof ChannelRegistryAware) {
|
||||
((ChannelRegistryAware) this.handler).setChannelRegistry(channelRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelector(MessageSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
@@ -95,17 +102,6 @@ public class DefaultEndpoint<T extends MessageHandler> extends AbstractRequestRe
|
||||
}
|
||||
}
|
||||
|
||||
public void setChannelRegistry(ChannelRegistry channelRegistry) {
|
||||
if (this.handler instanceof ChannelRegistryAware) {
|
||||
((ChannelRegistryAware) this.handler).setChannelRegistry(channelRegistry);
|
||||
}
|
||||
this.channelRegistry = channelRegistry;
|
||||
}
|
||||
|
||||
protected ChannelRegistry getChannelRegistry() {
|
||||
return this.channelRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the timeout for sending reply Messages to the reply
|
||||
* target. The default value indicates an indefinite timeout.
|
||||
@@ -222,7 +218,7 @@ public class DefaultEndpoint<T extends MessageHandler> extends AbstractRequestRe
|
||||
replyTarget = (MessageTarget) targetAttribute;
|
||||
}
|
||||
else if (targetAttribute instanceof String) {
|
||||
ChannelRegistry registry = getChannelRegistry();
|
||||
ChannelRegistry registry = this.getChannelRegistry();
|
||||
if (registry != null) {
|
||||
replyTarget = registry.lookupChannel((String) targetAttribute);
|
||||
}
|
||||
@@ -231,11 +227,6 @@ public class DefaultEndpoint<T extends MessageHandler> extends AbstractRequestRe
|
||||
return replyTarget;
|
||||
}
|
||||
|
||||
// TODO: remove
|
||||
|
||||
public void setReturnAddressOverrides(boolean returnAddressOverrides) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the channel where reply Messages should be sent if
|
||||
* no 'nextTarget' header value is available on the reply Message.
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
<si:channel id="replyChannel"/>
|
||||
<si:channel id="errorChannel"/>
|
||||
|
||||
<si:service-activator input-channel="channel1WithOverride" ref="testBean" method="duplicate"
|
||||
output-channel="channel2" return-address-overrides="true"/>
|
||||
|
||||
<si:service-activator input-channel="channel3WithOverride" ref="testBean" method="duplicate"
|
||||
return-address-overrides="true"/>
|
||||
|
||||
<si:service-activator input-channel="channel1WithOverride" ref="testBean" method="duplicate" output-channel="channel2"/>
|
||||
<si:service-activator input-channel="channel3WithOverride" ref="testBean" method="duplicate"/>
|
||||
<si:service-activator input-channel="channel1" ref="testBean" method="duplicate" output-channel="channel2"/>
|
||||
<si:service-activator input-channel="channel2" ref="testBean" method="duplicate" output-channel="channel3"/>
|
||||
<si:service-activator input-channel="channel3" ref="testBean" method="duplicate"/>
|
||||
|
||||
Reference in New Issue
Block a user