();
private volatile TaskExecutor taskExecutor;
@@ -46,18 +46,18 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
return "dispatcher";
}
- public boolean subscribe(MessageTarget target) {
- return this.targets.add(target);
+ public boolean subscribe(MessageEndpoint endpoint) {
+ return this.endpoints.add(endpoint);
}
- public boolean unsubscribe(MessageTarget target) {
- return this.targets.remove(target);
+ public boolean unsubscribe(MessageEndpoint endpoint) {
+ return this.endpoints.remove(endpoint);
}
/**
- * Specify a {@link TaskExecutor} for invoking the target endpoints.
+ * Specify a {@link TaskExecutor} for invoking the endpoints.
* If none is provided, the invocation will occur in the thread
- * that runs this polling dispatcher.
+ * that runs this polling dispatcher.
*/
public void setTaskExecutor(TaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
@@ -68,14 +68,14 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
}
/**
- * A convenience method for subclasses to send a Message to a single target.
+ * A convenience method for subclasses to send a Message to a single endpoint.
*/
- protected final boolean sendMessageToTarget(Message> message, MessageTarget target) {
- return target.send(message);
+ protected final boolean sendMessageToEndpoint(Message> message, MessageEndpoint endpoint) {
+ return endpoint.send(message);
}
public String toString() {
- return this.getClass().getSimpleName() + " with targets: " + this.targets;
+ return this.getClass().getSimpleName() + " with endpoints: " + this.endpoints;
}
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java
index e6d319cef8..2b44ef4523 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java
@@ -17,15 +17,15 @@
package org.springframework.integration.dispatcher;
import org.springframework.core.task.TaskExecutor;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageBuilder;
-import org.springframework.integration.message.MessageTarget;
/**
* A broadcasting dispatcher implementation. It makes a best effort to
- * send the message to each of its targets. If it fails to send to any
- * one target, it will log a warn-level message but continue to send
- * to the other targets.
+ * send the message to each of its endpoints. If it fails to send to any
+ * one endpoints, it will log a warn-level message but continue to send
+ * to the other endpoints.
*
* @author Mark Fisher
*/
@@ -36,7 +36,7 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
/**
* Specify whether to apply sequence numbers to the messages
- * prior to sending to the targets. By default, sequence
+ * prior to sending to the endpoints. By default, sequence
* numbers will not be applied
*/
public void setApplySequence(boolean applySequence) {
@@ -45,8 +45,8 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
public boolean send(Message> message) {
int sequenceNumber = 1;
- int sequenceSize = this.targets.size();
- for (final MessageTarget target : this.targets) {
+ int sequenceSize = this.endpoints.size();
+ for (final MessageEndpoint endpoint : this.endpoints) {
final Message> messageToSend = (!this.applySequence) ? message
: MessageBuilder.fromMessage(message)
.setSequenceNumber(sequenceNumber++)
@@ -56,12 +56,12 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
if (executor != null) {
executor.execute(new Runnable() {
public void run() {
- sendMessageToTarget(messageToSend, target);
+ sendMessageToEndpoint(messageToSend, endpoint);
}
});
}
else {
- this.sendMessageToTarget(messageToSend, target);
+ this.sendMessageToEndpoint(messageToSend, endpoint);
}
}
return true;
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/MessageDispatcher.java b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/MessageDispatcher.java
index a860faf309..752044fce8 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/MessageDispatcher.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/MessageDispatcher.java
@@ -17,8 +17,8 @@
package org.springframework.integration.dispatcher;
import org.springframework.integration.channel.MessageChannel;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
-import org.springframework.integration.message.MessageTarget;
import org.springframework.integration.message.SubscribableSource;
/**
@@ -30,8 +30,8 @@ public interface MessageDispatcher extends MessageChannel, SubscribableSource {
boolean send(Message> message);
- boolean subscribe(MessageTarget target);
+ boolean subscribe(MessageEndpoint endpoint);
- boolean unsubscribe(MessageTarget target);
+ boolean unsubscribe(MessageEndpoint endpoint);
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/PollingDispatcher.java b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/PollingDispatcher.java
index c9f0629fce..9ab4e68330 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/PollingDispatcher.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/PollingDispatcher.java
@@ -19,9 +19,9 @@ package org.springframework.integration.dispatcher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.BlockingSource;
import org.springframework.integration.message.MessageExchangeTemplate;
-import org.springframework.integration.message.MessageTarget;
import org.springframework.integration.message.PollableSource;
import org.springframework.integration.message.SubscribableSource;
import org.springframework.integration.scheduling.SchedulableTask;
@@ -99,12 +99,12 @@ public class PollingDispatcher implements SchedulableTask, SubscribableSource {
this.maxMessagesPerPoll = maxMessagesPerPoll;
}
- public boolean subscribe(MessageTarget target) {
- return this.dispatcher.subscribe(target);
+ public boolean subscribe(MessageEndpoint endpoint) {
+ return this.dispatcher.subscribe(endpoint);
}
- public boolean unsubscribe(MessageTarget target) {
- return this.dispatcher.unsubscribe(target);
+ public boolean unsubscribe(MessageEndpoint endpoint) {
+ return this.dispatcher.unsubscribe(endpoint);
}
public Schedule getSchedule() {
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/SimpleDispatcher.java b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/SimpleDispatcher.java
index 4f6517af98..8f5bbe6409 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/SimpleDispatcher.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/SimpleDispatcher.java
@@ -16,19 +16,19 @@
package org.springframework.integration.dispatcher;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessageRejectedException;
-import org.springframework.integration.message.MessageTarget;
/**
* Basic implementation of {@link MessageDispatcher} that will attempt
- * to send a {@link Message} to one of its targets. As soon as one
- * of the targets accepts the Message, the dispatcher will return 'true'.
+ * to send a {@link Message} to one of its endpoints. As soon as one
+ * of the endpoints accepts the Message, the dispatcher will return 'true'.
*
- * If the dispatcher has no targets, a {@link MessageDeliveryException}
- * will be thrown. If all targets reject the Message, the dispatcher will
- * throw a MessageRejectedException. If all targets return 'false'
+ * If the dispatcher has no endpoints, a {@link MessageDeliveryException}
+ * will be thrown. If all endpoints reject the Message, the dispatcher will
+ * throw a MessageRejectedException. If all endpoints return 'false'
* (e.g. due to a timeout), the dispatcher will return 'false'.
*
* @author Mark Fisher
@@ -36,30 +36,30 @@ import org.springframework.integration.message.MessageTarget;
public class SimpleDispatcher extends AbstractDispatcher {
public boolean send(Message> message) {
- if (this.targets.size() == 0) {
- throw new MessageDeliveryException(message, "Dispatcher has no targets.");
+ if (this.endpoints.size() == 0) {
+ throw new MessageDeliveryException(message, "Dispatcher has no subscribers.");
}
int count = 0;
int rejectedExceptionCount = 0;
- for (MessageTarget target : this.targets) {
+ for (MessageEndpoint endpoint : this.endpoints) {
count++;
try {
- if (this.sendMessageToTarget(message, target)) {
+ if (this.sendMessageToEndpoint(message, endpoint)) {
return true;
}
if (logger.isDebugEnabled()) {
- logger.debug("Failed to send message to target, continuing with other targets if available.");
+ logger.debug("Failed to send message to endpoint, continuing with other endpoints if available.");
}
}
catch (MessageRejectedException e) {
rejectedExceptionCount++;
if (logger.isDebugEnabled()) {
- logger.debug("Target '" + target + "' rejected Message, continuing with other targets if available.", e);
+ logger.debug("Endpoint '" + endpoint + "' rejected Message, continuing with other endpoints if available.", e);
}
}
}
if (rejectedExceptionCount == count) {
- throw new MessageRejectedException(message, "All of dispatcher's targets rejected Message.");
+ throw new MessageRejectedException(message, "All of dispatcher's endpoints rejected Message.");
}
return false;
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java
index ca1ba2fd41..7361a06bd8 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageEndpoint.java
@@ -16,18 +16,20 @@
package org.springframework.integration.endpoint;
+import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageSource;
-import org.springframework.integration.message.MessageTarget;
/**
* Base interface for message endpoints.
*
* @author Mark Fisher
*/
-public interface MessageEndpoint extends MessageTarget {
+public interface MessageEndpoint {
String getName();
MessageSource> getSource();
+ boolean send(Message> message);
+
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/message/SubscribableSource.java b/org.springframework.integration/src/main/java/org/springframework/integration/message/SubscribableSource.java
index 7722d061c9..1cc02ea853 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/message/SubscribableSource.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/message/SubscribableSource.java
@@ -16,6 +16,8 @@
package org.springframework.integration.message;
+import org.springframework.integration.endpoint.MessageEndpoint;
+
/**
* Interface for any source of messages that accepts subscribers.
*
@@ -24,13 +26,13 @@ package org.springframework.integration.message;
public interface SubscribableSource extends MessageSource {
/**
- * Register a {@link MessageTarget} as a subscriber to this source.
+ * Register a {@link MessageEndpoint} as a subscriber to this source.
*/
- boolean subscribe(MessageTarget target);
+ boolean subscribe(MessageEndpoint endpoint);
/**
- * Remove a {@link MessageTarget} from the subscribers of this source.
+ * Remove a {@link MessageEndpoint} from the subscribers of this source.
*/
- boolean unsubscribe(MessageTarget target);
+ boolean unsubscribe(MessageEndpoint endpoint);
}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/channel/DirectChannelTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/channel/DirectChannelTests.java
index 5e84a93b13..a0986cd4bb 100644
--- a/org.springframework.integration/src/test/java/org/springframework/integration/channel/DirectChannelTests.java
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/channel/DirectChannelTests.java
@@ -25,8 +25,9 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
-import org.springframework.integration.message.MessageTarget;
+import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.StringMessage;
/**
@@ -61,7 +62,7 @@ public class DirectChannelTests {
}
- private static class ThreadNameExtractingTestTarget implements MessageTarget {
+ private static class ThreadNameExtractingTestTarget implements MessageEndpoint {
private String threadName;
@@ -83,6 +84,15 @@ public class DirectChannelTests {
}
return true;
}
+
+ // TODO: remove once this is a consumer instead of endpoint
+ public String getName() {
+ return null;
+ }
+
+ public MessageSource> getSource() {
+ return null;
+ }
}
}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSubscribableSource.java b/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSubscribableSource.java
index 8950ff6822..78dff2df94 100644
--- a/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSubscribableSource.java
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSubscribableSource.java
@@ -19,8 +19,8 @@ package org.springframework.integration.channel.config;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
-import org.springframework.integration.message.MessageTarget;
import org.springframework.integration.message.SubscribableSource;
/**
@@ -28,20 +28,20 @@ import org.springframework.integration.message.SubscribableSource;
*/
public class TestSubscribableSource implements SubscribableSource {
- private final List targets = new CopyOnWriteArrayList();
+ private final List endpoints = new CopyOnWriteArrayList();
- public boolean subscribe(MessageTarget target) {
- return this.targets.add(target);
+ public boolean subscribe(MessageEndpoint endpoint) {
+ return this.endpoints.add(endpoint);
}
- public boolean unsubscribe(MessageTarget target) {
- return this.targets.remove(target);
+ public boolean unsubscribe(MessageEndpoint endpoint) {
+ return this.endpoints.remove(endpoint);
}
public void publishMessage(Message> message) {
- for (MessageTarget target : this.targets) {
- target.send(message);
+ for (MessageEndpoint endpoint : this.endpoints) {
+ endpoint.send(message);
}
}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/EndpointParserTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/EndpointParserTests.java
index 99ec92e286..f42173d1fe 100644
--- a/org.springframework.integration/src/test/java/org/springframework/integration/config/EndpointParserTests.java
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/EndpointParserTests.java
@@ -28,11 +28,11 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageBuilder;
import org.springframework.integration.message.MessageRejectedException;
-import org.springframework.integration.message.MessageTarget;
import org.springframework.integration.message.StringMessage;
/**
@@ -57,7 +57,7 @@ public class EndpointParserTests {
public void testEndpointWithSelectorAccepts() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"endpointWithSelector.xml", this.getClass());
- MessageTarget endpoint = (MessageTarget) context.getBean("endpoint");
+ MessageEndpoint endpoint = (MessageEndpoint) context.getBean("endpoint");
QueueChannel replyChannel = new QueueChannel();
Message> message = MessageBuilder.fromPayload("test")
.setReturnAddress(replyChannel).build();
@@ -71,7 +71,7 @@ public class EndpointParserTests {
public void testEndpointWithSelectorRejects() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"endpointWithSelector.xml", this.getClass());
- MessageTarget endpoint = (MessageTarget) context.getBean("endpoint");
+ MessageEndpoint endpoint = (MessageEndpoint) context.getBean("endpoint");
MessageChannel replyChannel = new QueueChannel();
Message> message = MessageBuilder.fromPayload(123)
.setReturnAddress(replyChannel).build();
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java
index b6dca4e3de..cdf056d63f 100644
--- a/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java
@@ -318,12 +318,18 @@ public class MessagingAnnotationPostProcessorTests {
DirectChannel testChannel = (DirectChannel) messageBus.lookupChannel("testChannel");
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference> receivedMessage = new AtomicReference>();
- testChannel.subscribe(new org.springframework.integration.message.MessageTarget() {
+ testChannel.subscribe(new org.springframework.integration.endpoint.MessageEndpoint() {
public boolean send(Message> message) {
receivedMessage.set(message);
latch.countDown();
return false;
}
+ public String getName() {
+ return null;
+ }
+ public MessageSource> getSource() {
+ return null;
+ }
});
latch.await(3, TimeUnit.SECONDS);
assertEquals(0, latch.getCount());
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/BroadcastingDispatcherTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/BroadcastingDispatcherTests.java
index 2320f97001..990356c399 100644
--- a/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/BroadcastingDispatcherTests.java
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/BroadcastingDispatcherTests.java
@@ -35,8 +35,9 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.core.task.TaskExecutor;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
-import org.springframework.integration.message.MessageTarget;
+import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.StringMessage;
/**
@@ -51,11 +52,11 @@ public class BroadcastingDispatcherTests {
private Message> messageMock = createMock(Message.class);
- private MessageTarget targetMock1 = createMock(MessageTarget.class);
+ private MessageEndpoint targetMock1 = createMock(MessageEndpoint.class);
- private MessageTarget targetMock2 = createMock(MessageTarget.class);
+ private MessageEndpoint targetMock2 = createMock(MessageEndpoint.class);
- private MessageTarget targetMock3 = createMock(MessageTarget.class);
+ private MessageEndpoint targetMock3 = createMock(MessageEndpoint.class);
private Object[] globalMocks = new Object[] {
messageMock, taskExecutorMock, targetMock1, targetMock2, targetMock3 };
@@ -213,8 +214,8 @@ public class BroadcastingDispatcherTests {
public void applySequenceDisabledByDefault() {
BroadcastingDispatcher dispatcher = new BroadcastingDispatcher();
final List> messages = Collections.synchronizedList(new ArrayList>());
- MessageTarget target1 = new MessageStoringTestTarget(messages);
- MessageTarget target2 = new MessageStoringTestTarget(messages);
+ MessageEndpoint target1 = new MessageStoringTestEndpoint(messages);
+ MessageEndpoint target2 = new MessageStoringTestEndpoint(messages);
dispatcher.subscribe(target1);
dispatcher.subscribe(target2);
dispatcher.send(new StringMessage("test"));
@@ -230,9 +231,9 @@ public class BroadcastingDispatcherTests {
BroadcastingDispatcher dispatcher = new BroadcastingDispatcher();
dispatcher.setApplySequence(true);
final List> messages = Collections.synchronizedList(new ArrayList>());
- MessageTarget target1 = new MessageStoringTestTarget(messages);
- MessageTarget target2 = new MessageStoringTestTarget(messages);
- MessageTarget target3 = new MessageStoringTestTarget(messages);
+ MessageEndpoint target1 = new MessageStoringTestEndpoint(messages);
+ MessageEndpoint target2 = new MessageStoringTestEndpoint(messages);
+ MessageEndpoint target3 = new MessageStoringTestEndpoint(messages);
dispatcher.subscribe(target1);
dispatcher.subscribe(target2);
dispatcher.subscribe(target3);
@@ -275,11 +276,11 @@ public class BroadcastingDispatcherTests {
}
- private static class MessageStoringTestTarget implements MessageTarget {
+ private static class MessageStoringTestEndpoint implements MessageEndpoint {
private final List> messageList;
- MessageStoringTestTarget(List> messageList) {
+ MessageStoringTestEndpoint(List> messageList) {
this.messageList = messageList;
}
@@ -287,6 +288,14 @@ public class BroadcastingDispatcherTests {
this.messageList.add(message);
return true;
}
+
+ public String getName() {
+ return null;
+ }
+
+ public MessageSource> getSource() {
+ return null;
+ }
};
}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/SimpleDispatcherTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/SimpleDispatcherTests.java
index be4c4d4323..ddfabc659a 100644
--- a/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/SimpleDispatcherTests.java
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/dispatcher/SimpleDispatcherTests.java
@@ -27,12 +27,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test;
import org.springframework.integration.endpoint.AbstractInOutEndpoint;
+import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
import org.springframework.integration.handler.TestHandlers;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessageRejectedException;
-import org.springframework.integration.message.MessageTarget;
+import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.message.selector.MessageSelector;
@@ -69,7 +70,7 @@ public class SimpleDispatcherTests {
public void noDuplicateSubscriptions() {
SimpleDispatcher dispatcher = new SimpleDispatcher();
final AtomicInteger counter = new AtomicInteger();
- MessageTarget target = new CountingTestTarget(counter, false);
+ MessageEndpoint target = new CountingTestEndpoint(counter, false);
dispatcher.subscribe(target);
dispatcher.subscribe(target);
dispatcher.send(new StringMessage("test"));
@@ -80,9 +81,9 @@ public class SimpleDispatcherTests {
public void unsubscribeBeforeSend() {
SimpleDispatcher dispatcher = new SimpleDispatcher();
final AtomicInteger counter = new AtomicInteger();
- MessageTarget target1 = new CountingTestTarget(counter, false);
- MessageTarget target2 = new CountingTestTarget(counter, false);
- MessageTarget target3 = new CountingTestTarget(counter, false);
+ MessageEndpoint target1 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target2 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target3 = new CountingTestEndpoint(counter, false);
dispatcher.subscribe(target1);
dispatcher.subscribe(target2);
dispatcher.subscribe(target3);
@@ -95,9 +96,9 @@ public class SimpleDispatcherTests {
public void unsubscribeBetweenSends() {
SimpleDispatcher dispatcher = new SimpleDispatcher();
final AtomicInteger counter = new AtomicInteger();
- MessageTarget target1 = new CountingTestTarget(counter, false);
- MessageTarget target2 = new CountingTestTarget(counter, false);
- MessageTarget target3 = new CountingTestTarget(counter, false);
+ MessageEndpoint target1 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target2 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target3 = new CountingTestEndpoint(counter, false);
dispatcher.subscribe(target1);
dispatcher.subscribe(target2);
dispatcher.subscribe(target3);
@@ -115,7 +116,7 @@ public class SimpleDispatcherTests {
public void unsubscribeLastTargetCausesDeliveryException() {
SimpleDispatcher dispatcher = new SimpleDispatcher();
final AtomicInteger counter = new AtomicInteger();
- MessageTarget target = new CountingTestTarget(counter, false);
+ MessageEndpoint target = new CountingTestEndpoint(counter, false);
dispatcher.subscribe(target);
dispatcher.send(new StringMessage("test1"));
assertEquals(1, counter.get());
@@ -183,9 +184,9 @@ public class SimpleDispatcherTests {
public void firstHandlerReturnsTrue() {
SimpleDispatcher dispatcher = new SimpleDispatcher();
final AtomicInteger counter = new AtomicInteger();
- MessageTarget target1 = new CountingTestTarget(counter, true);
- MessageTarget target2 = new CountingTestTarget(counter, false);
- MessageTarget target3 = new CountingTestTarget(counter, false);
+ MessageEndpoint target1 = new CountingTestEndpoint(counter, true);
+ MessageEndpoint target2 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target3 = new CountingTestEndpoint(counter, false);
dispatcher.subscribe(target1);
dispatcher.subscribe(target2);
dispatcher.subscribe(target3);
@@ -197,9 +198,9 @@ public class SimpleDispatcherTests {
public void middleHandlerReturnsTrue() {
SimpleDispatcher dispatcher = new SimpleDispatcher();
final AtomicInteger counter = new AtomicInteger();
- MessageTarget target1 = new CountingTestTarget(counter, false);
- MessageTarget target2 = new CountingTestTarget(counter, true);
- MessageTarget target3 = new CountingTestTarget(counter, false);
+ MessageEndpoint target1 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target2 = new CountingTestEndpoint(counter, true);
+ MessageEndpoint target3 = new CountingTestEndpoint(counter, false);
dispatcher.subscribe(target1);
dispatcher.subscribe(target2);
dispatcher.subscribe(target3);
@@ -211,9 +212,9 @@ public class SimpleDispatcherTests {
public void allHandlersReturnFalse() {
SimpleDispatcher dispatcher = new SimpleDispatcher();
final AtomicInteger counter = new AtomicInteger();
- MessageTarget target1 = new CountingTestTarget(counter, false);
- MessageTarget target2 = new CountingTestTarget(counter, false);
- MessageTarget target3 = new CountingTestTarget(counter, false);
+ MessageEndpoint target1 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target2 = new CountingTestEndpoint(counter, false);
+ MessageEndpoint target3 = new CountingTestEndpoint(counter, false);
dispatcher.subscribe(target1);
dispatcher.subscribe(target2);
dispatcher.subscribe(target3);
@@ -245,13 +246,13 @@ public class SimpleDispatcherTests {
}
- private static class CountingTestTarget implements MessageTarget {
+ private static class CountingTestEndpoint implements MessageEndpoint {
private final AtomicInteger counter;
private final boolean returnValue;
- CountingTestTarget(AtomicInteger counter, boolean returnValue) {
+ CountingTestEndpoint(AtomicInteger counter, boolean returnValue) {
this.counter = counter;
this.returnValue = returnValue;
}
@@ -260,6 +261,14 @@ public class SimpleDispatcherTests {
this.counter.incrementAndGet();
return this.returnValue;
}
+
+ public String getName() {
+ return null;
+ }
+
+ public MessageSource> getSource() {
+ return null;
+ }
}
}