Refactored existing Message-consuming endpoints to only implement MessageConsumer (not MessageEndpoint). Now, either a PollingConsumerEndpoint or SubscribingConsumerEndpoint delegates to the MessageConsumer thereby separating the Lifecycle responsibilities and configuration settings (trigger, transactions, etc) since they are different for polling vs. subscribing and not relevant for simply consuming Messages. Essentially all MessageConsumers are now "event-driven" since a "polling consumer" is actually handled by the PollingConsumerEndpoint class. The next refactoring step involves renaming several components to clarify this endpoint vs. consumer distinction.

This commit is contained in:
Mark Fisher
2008-10-06 17:24:46 +00:00
parent 14cd44d272
commit 27e288be08
54 changed files with 591 additions and 682 deletions

View File

@@ -39,10 +39,6 @@ public abstract class AbstractRemotingOutboundGateway extends AbstractMessageHan
}
public void setRequestChannel(MessageChannel requestChannel) {
this.setInputChannel(requestChannel);
}
public void setReplyChannel(MessageChannel replyChannel) {
this.setOutputChannel(replyChannel);
}

View File

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.endpoint.config.ConsumerEndpointFactoryBean;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -33,7 +34,9 @@ import org.springframework.util.StringUtils;
*/
public abstract class AbstractRemotingGatewayParser extends AbstractSimpleBeanDefinitionParser {
protected abstract Class<?> getBeanClass(Element element);
protected Class<?> getBeanClass(Element element) {
return ConsumerEndpointFactoryBean.class;
}
@Override

View File

@@ -18,26 +18,64 @@ package org.springframework.integration.adapter.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.AbstractEndpointParser;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Base class for url-based remoting outbound gateway parsers.
*
* @author Mark Fisher
*/
public abstract class AbstractRemotingOutboundGatewayParser extends AbstractRemotingGatewayParser {
public abstract class AbstractRemotingOutboundGatewayParser extends AbstractEndpointParser {
protected abstract Class<?> getGatewayClass(Element element);
@Override
protected boolean isEligibleAttribute(String attributeName) {
return !attributeName.equals("url") && super.isEligibleAttribute(attributeName);
protected String getInputChannelAttributeName() {
return "request-channel";
}
@Override
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
throws BeanDefinitionStoreException {
String id = super.resolveId(element, definition, parserContext);
if (!StringUtils.hasText(id)) {
id = element.getAttribute("name");
}
if (!StringUtils.hasText(id)) {
id = parserContext.getReaderContext().generateBeanName(definition);
}
return id;
}
@Override
protected BeanDefinitionBuilder parseConsumer(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(this.getGatewayClass(element));
String url = this.parseUrl(element);
builder.addConstructorArgValue(url);
String replyChannel = element.getAttribute("reply-channel");
if (StringUtils.hasText(replyChannel)) {
builder.addPropertyReference("replyChannel", replyChannel);
}
this.postProcessGateway(builder, element);
return builder;
}
protected String parseUrl(Element element) {
String url = element.getAttribute("url");
Assert.hasText(url, "The 'url' attribute is required.");
builder.addConstructorArgValue(url);
return url;
}
/**
* Subclasses may override this method for additional configuration.
*/
protected void postProcessGateway(BeanDefinitionBuilder builder, Element element) {
}
}