Renamed the 'defaultReplyChannel' property to 'outputChannel' (and renamed the corresponding xml attributes) for the aggregator and resequencer.

This commit is contained in:
Mark Fisher
2008-07-29 22:51:33 +00:00
parent 07efae79e6
commit 83399a95cb
13 changed files with 78 additions and 98 deletions

View File

@@ -54,20 +54,6 @@ public class AggregatorParser extends AbstractHandlerEndpointParser {
private static final String COMPLETION_STRATEGY_PROPERTY = "completionStrategy";
private static final String DEFAULT_REPLY_CHANNEL_PROPERTY = "defaultReplyChannel";
private static final String DISCARD_CHANNEL_PROPERTY = "discardChannel";
private static final String SEND_TIMEOUT_PROPERTY = "sendTimeout";
private static final String SEND_PARTIAL_RESULT_ON_TIMEOUT_PROPERTY = "sendPartialResultOnTimeout";
private static final String REAPER_INTERVAL_PROPERTY = "reaperInterval";
public static final String TRACKED_CORRELATION_ID_CAPACITY_PROPERTY = "trackedCorrelationIdCapacity";
public static final String TIMEOUT = "timeout";
public static final String AGGREGATOR_ELEMENT = "aggregator";
@@ -103,19 +89,13 @@ public class AggregatorParser extends AbstractHandlerEndpointParser {
builder.addPropertyReference(COMPLETION_STRATEGY_PROPERTY, completionStrategyRef);
}
}
IntegrationNamespaceUtils.setBeanReferenceIfAttributeDefined(builder, DEFAULT_REPLY_CHANNEL_PROPERTY,
element, OUTPUT_CHANNEL_ATTRIBUTE);
IntegrationNamespaceUtils.setBeanReferenceIfAttributeDefined(builder, DISCARD_CHANNEL_PROPERTY, element,
DISCARD_CHANNEL_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, SEND_TIMEOUT_PROPERTY, element,
SEND_TIMEOUT_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, SEND_PARTIAL_RESULT_ON_TIMEOUT_PROPERTY,
element, SEND_PARTIAL_RESULT_ON_TIMEOUT_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, REAPER_INTERVAL_PROPERTY, element,
REAPER_INTERVAL_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, TRACKED_CORRELATION_ID_CAPACITY_PROPERTY,
element, TRACKED_CORRELATION_ID_CAPACITY_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, TIMEOUT, element, TIMEOUT_ATTRIBUTE);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, OUTPUT_CHANNEL_ATTRIBUTE);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, DISCARD_CHANNEL_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, SEND_TIMEOUT_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, SEND_PARTIAL_RESULT_ON_TIMEOUT_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, REAPER_INTERVAL_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, TRACKED_CORRELATION_ID_CAPACITY_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, TIMEOUT_ATTRIBUTE);
return BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), parserContext.getRegistry());
}

View File

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
import org.springframework.integration.message.AsyncMessageExchangeTemplate;
import org.springframework.integration.message.MessageExchangeTemplate;
import org.springframework.transaction.support.DefaultTransactionDefinition;
@@ -39,38 +40,47 @@ import org.springframework.util.xml.DomUtils;
public abstract class IntegrationNamespaceUtils {
/**
* Populates the property identified by propertyName on the bean definition
* to the value of the attribute specified by attributeName, if that
* attribute is defined in the element
* Populates the bean definition property corresponding to the specified
* attributeName with the value of that attribute if it is defined in the
* given element. The property name will be the camel-case equivalent of
* the lower case hyphen separated attribute (e.g. the "foo-bar" attribute
* would match the "fooBar" property).
*
* @param beanDefinition - the bean definition to be configured
* @param propertyName - the name of the bean property to be set
* @param element - the XML element where the attribute should be defined
* @param attributeName - the name of the attribute whose value will be set
* on the property
*
* @see Conventions#attributeNameToPropertyName(String)
*/
public static void setValueIfAttributeDefined(BeanDefinitionBuilder builder, String propertyName,
public static void setValueIfAttributeDefined(BeanDefinitionBuilder builder,
Element element, String attributeName) {
final String attributeValue = element.getAttribute(attributeName);
String attributeValue = element.getAttribute(attributeName);
String propertyName = Conventions.attributeNameToPropertyName(attributeName);
if (StringUtils.hasText(attributeValue)) {
builder.addPropertyValue(propertyName, attributeValue);
}
}
/**
* Populates the property given by propertyName on the given bean definition
* to a reference to a bean identified by the value of the attribute
* specified by attributeName, if that attribute is defined in the element
* Populates the bean definition property corresponding to the specified
* attributeName with the reference to a bean identified by the value of
* that attribute if the attribute is defined in the given element. The
* property name will be the camel-case equivalent of the lower case
* hyphen separated attribute (e.g. the "foo-bar" attribute would match
* the "fooBar" property).
*
* @param beanDefinition - the bean definition to be configured
* @param propertyName - the name of the bean property to be set
* @param element - the XML element where the attribute should be defined
* @param attributeName - the id of the bean which will be used to populate
* the property
* @param attributeName - the name of the attribute whose value will be
* used as a bean reference to populate the property
*
* @see Conventions#attributeNameToPropertyName(String)
*/
public static void setBeanReferenceIfAttributeDefined(BeanDefinitionBuilder builder, String propertyName,
public static void setReferenceIfAttributeDefined(BeanDefinitionBuilder builder,
Element element, String attributeName) {
final String attributeValue = element.getAttribute(attributeName);
String attributeValue = element.getAttribute(attributeName);
String propertyName = Conventions.attributeNameToPropertyName(attributeName);
if (StringUtils.hasText(attributeValue)) {
builder.addPropertyReference(propertyName, attributeValue);
}

View File

@@ -409,7 +409,7 @@
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="default-reply-channel" type="xsd:string" use="optional"/>
<xsd:attribute name="output-channel" type="xsd:string" use="optional"/>
<xsd:attribute name="discard-channel" type="xsd:string" use="optional"/>
<xsd:attribute name="send-timeout" type="xsd:long" use="optional"/>
<xsd:attribute name="release-partial-sequences" type="xsd:boolean" use="optional"/>

View File

@@ -69,7 +69,7 @@ public abstract class AbstractMessageBarrierHandler implements MessageHandler, I
protected final Log logger = LogFactory.getLog(this.getClass());
protected volatile MessageChannel defaultReplyChannel;
protected volatile MessageChannel outputChannel;
private volatile MessageChannel discardChannel;
@@ -99,12 +99,12 @@ public abstract class AbstractMessageBarrierHandler implements MessageHandler, I
/**
* Set the default channel for sending aggregated Messages. Note that
* Set the output channel for sending aggregated Messages. Note that
* precedence will be given to the 'returnAddress' of the aggregated
* message itself, then to the 'returnAddress' of the original message.
*/
public void setDefaultReplyChannel(MessageChannel defaultReplyChannel) {
this.defaultReplyChannel = defaultReplyChannel;
public void setOutputChannel(MessageChannel outputChannel) {
this.outputChannel = outputChannel;
}
/**
@@ -204,7 +204,7 @@ public abstract class AbstractMessageBarrierHandler implements MessageHandler, I
if (replyChannel == null) {
replyChannel = this.resolveReplyChannelFromMessage(releasedMessages.get(0));
if (replyChannel == null) {
replyChannel = this.defaultReplyChannel;
replyChannel = this.outputChannel;
}
}
if (replyChannel != null) {

View File

@@ -95,7 +95,7 @@ public class AggregatorMessageHandlerCreator extends AbstractMessageHandlerCreat
if (endpointAnnotation != null) {
String outputChannelName = endpointAnnotation.output();
if (StringUtils.hasText(outputChannelName)) {
handler.setDefaultReplyChannel(this.channelRegistry.lookupChannel(outputChannelName));
handler.setOutputChannel(this.channelRegistry.lookupChannel(outputChannelName));
}
}
}

View File

@@ -20,8 +20,8 @@ import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.integration.config.IntegrationNamespaceUtils;
import org.springframework.integration.router.ResequencingMessageHandler;
import org.springframework.util.StringUtils;
/**
* Parser for the &lt;resequencer&gt; tag.
@@ -30,14 +30,10 @@ import org.springframework.util.StringUtils;
*/
public class ResequencerParser extends AbstractSimpleBeanDefinitionParser {
public static final String DEFAULT_REPLY_CHANNEL_ATTRIBUTE = "default-reply-channel";
public static final String OUTPUT_CHANNEL_ATTRIBUTE = "output-channel";
public static final String DISCARD_CHANNEL_ATTRIBUTE = "discard-channel";
private static final String DEFAULT_REPLY_CHANNEL_PROPERTY = "defaultReplyChannel";
private static final String DISCARD_CHANNEL_PROPERTY = "discardChannel";
@Override
protected Class<?> getBeanClass(Element element) {
@@ -46,21 +42,15 @@ public class ResequencerParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected boolean isEligibleAttribute(String attributeName) {
return !DEFAULT_REPLY_CHANNEL_ATTRIBUTE.equals(attributeName)
return !OUTPUT_CHANNEL_ATTRIBUTE.equals(attributeName)
&& !DISCARD_CHANNEL_ATTRIBUTE.equals(attributeName)
&& super.isEligibleAttribute(attributeName);
}
@Override
protected void postProcess(BeanDefinitionBuilder beanDefinition, Element element) {
if (StringUtils.hasText(element.getAttribute(DEFAULT_REPLY_CHANNEL_ATTRIBUTE))) {
beanDefinition.addPropertyReference(DEFAULT_REPLY_CHANNEL_PROPERTY,
element.getAttribute(DEFAULT_REPLY_CHANNEL_ATTRIBUTE));
}
if (StringUtils.hasText(element.getAttribute(DISCARD_CHANNEL_ATTRIBUTE))) {
beanDefinition.addPropertyReference(DISCARD_CHANNEL_PROPERTY,
element.getAttribute(DISCARD_CHANNEL_ATTRIBUTE));
}
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, OUTPUT_CHANNEL_ATTRIBUTE);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, DISCARD_CHANNEL_ATTRIBUTE);
}
}