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

@@ -20,7 +20,6 @@ import java.rmi.registry.Registry;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.integration.adapter.config.AbstractRemotingOutboundGatewayParser;
import org.springframework.integration.rmi.RmiInboundGateway;
import org.springframework.integration.rmi.RmiOutboundGateway;
@@ -35,28 +34,19 @@ import org.springframework.util.StringUtils;
public class RmiOutboundGatewayParser extends AbstractRemotingOutboundGatewayParser {
@Override
protected Class<?> getBeanClass(Element element) {
protected Class<?> getGatewayClass(Element element) {
return RmiOutboundGateway.class;
}
@Override
protected boolean isEligibleAttribute(String attributeName) {
return !"host".equals(attributeName)
&& !"port".equals(attributeName)
&& !"remote-channel".equals(attributeName)
&& super.isEligibleAttribute(attributeName);
}
@Override
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
protected String parseUrl(Element element) {
String host = element.getAttribute("host");
String remoteChannel = element.getAttribute("remote-channel");
Assert.isTrue(StringUtils.hasText(host) && StringUtils.hasText(remoteChannel),
"The 'host' and 'remote-channel' attributes are both required");
String portAttribute = element.getAttribute("port");
String port = StringUtils.hasText(portAttribute) ? portAttribute : "" + Registry.REGISTRY_PORT;
String url = "rmi://" + host + ":" + port + "/" + RmiInboundGateway.SERVICE_NAME_PREFIX + remoteChannel;
builder.addConstructorArgValue(url);
return "rmi://" + host + ":" + port + "/" + RmiInboundGateway.SERVICE_NAME_PREFIX + remoteChannel;
}
}

View File

@@ -29,7 +29,6 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.rmi.RmiInboundGateway;
import org.springframework.integration.rmi.RmiOutboundGateway;
/**
* @author Mark Fisher
@@ -53,8 +52,8 @@ public class RmiOutboundGatewayParserTests {
public void directInvocation() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"rmiOutboundGatewayParserTests.xml", this.getClass());
RmiOutboundGateway gateway = (RmiOutboundGateway) context.getBean("gateway");
gateway.handle(new StringMessage("test"));
MessageChannel localChannel = (MessageChannel) context.getBean("localChannel");
localChannel.send(new StringMessage("test"));
Message<?> result = testChannel.receive(1000);
assertNotNull(result);
assertEquals("test", result.getPayload());