MessageEndpoint no longer extends the MessageTarget interface.

This commit is contained in:
Mark Fisher
2008-09-07 01:48:34 +00:00
parent 4eaec4ce68
commit 673d7d250b
24 changed files with 244 additions and 192 deletions

View File

@@ -17,13 +17,13 @@
package org.springframework.integration.channel;
import org.springframework.integration.dispatcher.SimpleDispatcher;
import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.SubscribableSource;
import org.springframework.integration.message.MessageTarget;
/**
* A channel that invokes the subscribed {@link MessageTarget target(s)} in
* the sender's thread (returning after at most one handles the message).
* A channel that invokes the subscribed {@link MessageEndpoint endpoint(s)}
* in the sender's thread (returning after at most one accepts the message).
*
* @author Dave Syer
* @author Mark Fisher
@@ -33,12 +33,12 @@ public class DirectChannel extends AbstractMessageChannel implements Subscribabl
private final SimpleDispatcher dispatcher = new SimpleDispatcher();
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);
}
@Override

View File

@@ -18,8 +18,8 @@ package org.springframework.integration.channel;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageTarget;
import org.springframework.integration.message.SubscribableSource;
/**
@@ -48,12 +48,12 @@ public class PublishSubscribeChannel extends AbstractMessageChannel implements S
this.dispatcher.setApplySequence(applySequence);
}
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);
}
@Override

View File

@@ -23,8 +23,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageTarget;
/**
* Base class for {@link MessageDispatcher} implementations.
@@ -35,7 +35,7 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
protected final Log logger = LogFactory.getLog(this.getClass());
protected final Set<MessageTarget> targets = new CopyOnWriteArraySet<MessageTarget>();
protected final Set<MessageEndpoint> endpoints = new CopyOnWriteArraySet<MessageEndpoint>();
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;
}
}

View File

@@ -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 <em>not</em> 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;

View File

@@ -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);
}

View File

@@ -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() {

View File

@@ -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 <em>one</em>
* of the targets accepts the Message, the dispatcher will return 'true'.
* to send a {@link Message} to one of its endpoints. As soon as <em>one</em>
* of the endpoints accepts the Message, the dispatcher will return 'true'.
* <p>
* 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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;
}
}
}

View File

@@ -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<MessageTarget> targets = new CopyOnWriteArrayList<MessageTarget>();
private final List<MessageEndpoint> endpoints = new CopyOnWriteArrayList<MessageEndpoint>();
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);
}
}

View File

@@ -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();

View File

@@ -318,12 +318,18 @@ public class MessagingAnnotationPostProcessorTests {
DirectChannel testChannel = (DirectChannel) messageBus.lookupChannel("testChannel");
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Message<?>> receivedMessage = new AtomicReference<Message<?>>();
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());

View File

@@ -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<Message<?>> messages = Collections.synchronizedList(new ArrayList<Message<?>>());
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<Message<?>> messages = Collections.synchronizedList(new ArrayList<Message<?>>());
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<Message<?>> messageList;
MessageStoringTestTarget(List<Message<?>> messageList) {
MessageStoringTestEndpoint(List<Message<?>> 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;
}
};
}

View File

@@ -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;
}
}
}