Renamed MessageExchangeTemplate to MessageChannelTemplate.

This commit is contained in:
Mark Fisher
2008-09-09 10:36:29 +00:00
parent 04bb57f58d
commit 2a2d076b36
12 changed files with 48 additions and 49 deletions

View File

@@ -24,7 +24,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.ChannelRegistry;
import org.springframework.integration.channel.ChannelRegistryAware;
import org.springframework.integration.message.MessageExchangeTemplate;
import org.springframework.integration.message.MessageChannelTemplate;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.scheduling.TaskScheduler;
import org.springframework.integration.scheduling.TaskSchedulerAware;
@@ -53,7 +53,7 @@ public abstract class AbstractEndpoint implements MessageEndpoint, ChannelRegist
private volatile ErrorHandler errorHandler;
private final MessageExchangeTemplate messageExchangeTemplate = new MessageExchangeTemplate();
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
/**
@@ -91,8 +91,8 @@ public abstract class AbstractEndpoint implements MessageEndpoint, ChannelRegist
this.transactionDefinition= transactionDefinition;
}
protected MessageExchangeTemplate getMessageExchangeTemplate() {
return this.messageExchangeTemplate;
protected MessageChannelTemplate getChannelTemplate() {
return this.channelTemplate;
}
/**

View File

@@ -138,7 +138,7 @@ public abstract class AbstractInOutEndpoint extends AbstractMessageConsumingEndp
}
}
}
return this.getMessageExchangeTemplate().send(replyMessage, replyChannel);
return this.getChannelTemplate().send(replyMessage, replyChannel);
}
private Message<?> buildReplyMessage(Object result, MessageHeaders requestHeaders) {

View File

@@ -17,10 +17,10 @@
package org.springframework.integration.gateway;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.MessageExchangeTemplate;
import org.springframework.integration.message.MessageChannelTemplate;
/**
* A convenient base class providing access to a {@link MessageExchangeTemplate} and exposing setter methods for
* A convenient base class providing access to a {@link MessageChannelTemplate} and exposing setter methods for
* configuring request and reply {@link MessageChannel MessageChannels}. May be used as a base class for framework
* components so that the details of messaging are well-encapsulated and hidden from application code. For example,
* see {@link SimpleMessagingGateway}.
@@ -29,7 +29,7 @@ import org.springframework.integration.message.MessageExchangeTemplate;
*/
public abstract class MessagingGatewaySupport {
private final MessageExchangeTemplate messageExchangeTemplate = new MessageExchangeTemplate();
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
/**
@@ -39,7 +39,7 @@ public abstract class MessagingGatewaySupport {
* @param requestTimeout the timeout value in milliseconds
*/
public void setRequestTimeout(long requestTimeout) {
this.messageExchangeTemplate.setSendTimeout(requestTimeout);
this.channelTemplate.setSendTimeout(requestTimeout);
}
/**
@@ -49,15 +49,15 @@ public abstract class MessagingGatewaySupport {
* @param replyTimeout the timeout value in milliseconds
*/
public void setReplyTimeout(long replyTimeout) {
this.messageExchangeTemplate.setReceiveTimeout(replyTimeout);
this.channelTemplate.setReceiveTimeout(replyTimeout);
}
/**
* Retrieve the {@link MessageExchangeTemplate} for performing
* Retrieve the {@link MessageChannelTemplate} for performing
* send and receive operations across channels.
*/
protected final MessageExchangeTemplate getMessageExchangeTemplate() {
return this.messageExchangeTemplate;
protected final MessageChannelTemplate getChannelTemplate() {
return this.channelTemplate;
}
}

View File

@@ -126,7 +126,7 @@ public class SimpleMessagingGateway extends MessagingGatewaySupport implements M
Message<?> message = (object instanceof Message) ? (Message) object :
this.messageCreator.createMessage(object);
if (message != null) {
if (!this.getMessageExchangeTemplate().send(message, this.requestChannel)) {
if (!this.getChannelTemplate().send(message, this.requestChannel)) {
throw new MessageDeliveryException(message, "failed to send Message to channel");
}
}
@@ -137,7 +137,7 @@ public class SimpleMessagingGateway extends MessagingGatewaySupport implements M
throw new IllegalStateException(
"no-arg receive is not supported, because no reply channel has been configured");
}
Message<?> message = this.getMessageExchangeTemplate().receive(this.replyChannel);
Message<?> message = this.getChannelTemplate().receive(this.replyChannel);
return (message != null) ? this.messageMapper.mapMessage(message) : null;
}
@@ -171,7 +171,7 @@ public class SimpleMessagingGateway extends MessagingGatewaySupport implements M
return this.sendAndReceiveWithReplyMessageCorrelator(message);
}
else {
return this.getMessageExchangeTemplate().sendAndReceive(message, this.requestChannel);
return this.getChannelTemplate().sendAndReceive(message, this.requestChannel);
}
}

View File

@@ -25,16 +25,16 @@ import org.springframework.integration.channel.PollableChannel;
import org.springframework.util.Assert;
/**
* An asynchronous version of the {@link MessageExchangeTemplate}.
* An asynchronous version of the {@link MessageChannelTemplate}.
*
* @author Mark Fisher
*/
public class AsyncMessageExchangeTemplate extends MessageExchangeTemplate {
public class AsyncMessageChannelTemplate extends MessageChannelTemplate {
private final TaskExecutor taskExecutor;
public AsyncMessageExchangeTemplate(TaskExecutor taskExecutor) {
public AsyncMessageChannelTemplate(TaskExecutor taskExecutor) {
Assert.notNull(taskExecutor, "TaskExecutor must not be null");
this.taskExecutor = taskExecutor;
}
@@ -49,7 +49,7 @@ public class AsyncMessageExchangeTemplate extends MessageExchangeTemplate {
public boolean send(final Message<?> message, final MessageChannel channel) {
this.taskExecutor.execute(new Runnable() {
public void run() {
AsyncMessageExchangeTemplate.super.send(message, channel);
AsyncMessageChannelTemplate.super.send(message, channel);
}
});
return true;
@@ -64,7 +64,7 @@ public class AsyncMessageExchangeTemplate extends MessageExchangeTemplate {
public Message<?> sendAndReceive(final Message<?> request, final MessageChannel channel) {
FutureTask<Message<?>> task = new FutureTask<Message<?>>(new Callable<Message<?>>() {
public Message<?> call() throws Exception {
return AsyncMessageExchangeTemplate.super.sendAndReceive(request, channel);
return AsyncMessageChannelTemplate.super.sendAndReceive(request, channel);
}
});
this.taskExecutor.execute(task);
@@ -79,7 +79,7 @@ public class AsyncMessageExchangeTemplate extends MessageExchangeTemplate {
public Message<?> receive(final PollableChannel channel) {
FutureTask<Message<?>> task = new FutureTask<Message<?>>(new Callable<Message<?>>() {
public Message<?> call() throws Exception {
return AsyncMessageExchangeTemplate.super.receive(channel);
return AsyncMessageChannelTemplate.super.receive(channel);
}
});
this.taskExecutor.execute(task);

View File

@@ -46,7 +46,7 @@ import org.springframework.util.Assert;
*
* @author Mark Fisher
*/
public class MessageExchangeTemplate implements InitializingBean {
public class MessageChannelTemplate implements InitializingBean {
protected final Log logger = LogFactory.getLog(this.getClass());
@@ -73,7 +73,6 @@ public class MessageExchangeTemplate implements InitializingBean {
/**
* Specify the timeout value to use for send operations.
* Note that this value will only apply to {@link BlockingTarget}s.
*
* @param sendTimeout the send timeout in milliseconds
*/

View File

@@ -61,7 +61,7 @@ public class RouterEndpoint extends AbstractMessageConsumingEndpoint {
* default, there is no timeout, meaning the send will block indefinitely.
*/
public void setTimeout(long timeout) {
this.getMessageExchangeTemplate().setSendTimeout(timeout);
this.getChannelTemplate().setSendTimeout(timeout);
}
/**
@@ -81,7 +81,7 @@ public class RouterEndpoint extends AbstractMessageConsumingEndpoint {
if (results != null) {
for (MessageChannel channel : results) {
if (channel != null) {
if (this.getMessageExchangeTemplate().send(message, channel)) {
if (this.getChannelTemplate().send(message, channel)) {
sent = true;
}
}
@@ -89,11 +89,11 @@ public class RouterEndpoint extends AbstractMessageConsumingEndpoint {
}
if (!sent) {
if (this.defaultOutputChannel != null) {
sent = this.getMessageExchangeTemplate().send(message, this.defaultOutputChannel);
sent = this.getChannelTemplate().send(message, this.defaultOutputChannel);
}
else if (this.resolutionRequired) {
throw new MessageDeliveryException(message,
"no target resolved by router and no default output channel defined");
"no channel resolved by router and no default output channel defined");
}
}
}

View File

@@ -36,7 +36,7 @@ import org.springframework.integration.endpoint.AbstractInOutEndpoint;
/**
* @author Mark Fisher
*/
public class MessageExchangeTemplateTests {
public class MessageChannelTemplateTests {
private QueueChannel requestChannel;
@@ -61,7 +61,7 @@ public class MessageExchangeTemplateTests {
@Test
public void testSendAndReceive() {
MessageExchangeTemplate template = new MessageExchangeTemplate();
MessageChannelTemplate template = new MessageChannelTemplate();
Message<?> reply = template.sendAndReceive(new StringMessage("test"), this.requestChannel);
assertEquals("TEST", reply.getPayload());
}
@@ -80,7 +80,7 @@ public class MessageExchangeTemplateTests {
return true;
}
};
MessageExchangeTemplate template = new MessageExchangeTemplate();
MessageChannelTemplate template = new MessageChannelTemplate();
Message<String> message1 = MessageBuilder.fromPayload("test1").setReturnAddress(replyChannel).build();
Message<String> message2 = MessageBuilder.fromPayload("test2").setReturnAddress(replyChannel).build();
Message<String> message3 = MessageBuilder.fromPayload("test3").setReturnAddress(replyChannel).build();