ServiceActivatorEndpoint is now ServiceActivatingConsumer.
This commit is contained in:
@@ -100,10 +100,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean
|
||||
Annotation[] annotations = AnnotationUtils.getAnnotations(method);
|
||||
for (Annotation annotation : annotations) {
|
||||
MethodAnnotationPostProcessor postProcessor = postProcessors.get(annotation.annotationType());
|
||||
if (postProcessor != null) {
|
||||
if (!shouldCreateEndpoint(annotation)) {
|
||||
continue;
|
||||
}
|
||||
if (postProcessor != null && shouldCreateEndpoint(annotation)) {
|
||||
Object result = postProcessor.postProcess(bean, beanName, method, annotation);
|
||||
if (result != null && result instanceof MessageEndpoint) {
|
||||
String endpointBeanName = generateBeanName(beanName, method, annotation.annotationType());
|
||||
|
||||
@@ -20,9 +20,8 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.endpoint.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageMappingMethodInvoker;
|
||||
|
||||
/**
|
||||
* Post-processor for Methods annotated with {@link ServiceActivator @ServiceActivator}.
|
||||
@@ -38,8 +37,7 @@ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnot
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, ServiceActivator annotation) {
|
||||
MessageMappingMethodInvoker invoker = new MessageMappingMethodInvoker(bean, method);
|
||||
return new ServiceActivatorEndpoint(invoker);
|
||||
return new ServiceActivatingConsumer(bean, method);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@ import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.message.MessageMappingMethodInvoker;
|
||||
import org.springframework.integration.endpoint.ServiceActivatingConsumer;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <service-activator> element.
|
||||
@@ -32,9 +33,14 @@ public class ServiceActivatorParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@Override
|
||||
protected BeanDefinitionBuilder parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ServiceActivatorEndpoint.class);
|
||||
String constructorArg = this.parseAdapter(element, parserContext, MessageMappingMethodInvoker.class);
|
||||
builder.addConstructorArgReference(constructorArg);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ServiceActivatingConsumer.class);
|
||||
String ref = element.getAttribute(REF_ATTRIBUTE);
|
||||
Assert.hasText(ref, "The '" + REF_ATTRIBUTE + "' attribute is required.");
|
||||
builder.addConstructorArgReference(ref);
|
||||
if (StringUtils.hasText(element.getAttribute(METHOD_ATTRIBUTE))) {
|
||||
String method = element.getAttribute(METHOD_ATTRIBUTE);
|
||||
builder.addConstructorArgValue(method);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,19 +31,14 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ServiceActivatorEndpoint extends AbstractReplyProducingMessageConsumer implements InitializingBean {
|
||||
public class ServiceActivatingConsumer extends AbstractReplyProducingMessageConsumer implements InitializingBean {
|
||||
|
||||
private final MethodResolver methodResolver = new DefaultMethodResolver(ServiceActivator.class);
|
||||
|
||||
private final MethodInvoker invoker;
|
||||
|
||||
|
||||
public ServiceActivatorEndpoint(MethodInvoker invoker) {
|
||||
Assert.notNull(invoker, "invoker must not be null");
|
||||
this.invoker = invoker;
|
||||
}
|
||||
|
||||
public ServiceActivatorEndpoint(final Object object) {
|
||||
public ServiceActivatingConsumer(final Object object) {
|
||||
Assert.notNull(object, "object must not be null");
|
||||
Method method = this.methodResolver.findMethod(object);
|
||||
Assert.notNull(method, "unable to resolve ServiceActivator method on target class ["
|
||||
@@ -51,8 +46,12 @@ public class ServiceActivatorEndpoint extends AbstractReplyProducingMessageConsu
|
||||
this.invoker = new MessageMappingMethodInvoker(object, method);
|
||||
}
|
||||
|
||||
public ServiceActivatorEndpoint(Object object, String methodName) {
|
||||
this(new MessageMappingMethodInvoker(object, methodName));
|
||||
public ServiceActivatingConsumer(Object object, Method method) {
|
||||
this.invoker = new MessageMappingMethodInvoker(object, method);
|
||||
}
|
||||
|
||||
public ServiceActivatingConsumer(Object object, String methodName) {
|
||||
this.invoker = new MessageMappingMethodInvoker(object, methodName);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +73,7 @@ public class ServiceActivatorEndpoint extends AbstractReplyProducingMessageConsu
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
throw new MessageHandlingException(message, "failure occurred in endpoint '" + this + "'", e);
|
||||
throw new MessageHandlingException(message, "failure occurred in Service Activator '" + this + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.integration.config.annotation.MessagingAnnotationPost
|
||||
import org.springframework.integration.config.xml.MessageBusParser;
|
||||
import org.springframework.integration.endpoint.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.endpoint.ReplyMessageHolder;
|
||||
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.endpoint.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
@@ -67,7 +67,7 @@ public class DirectChannelSubscriptionTests {
|
||||
@Test
|
||||
public void sendAndReceiveForRegisteredEndpoint() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ServiceActivatorEndpoint serviceActivator = new ServiceActivatorEndpoint(new TestBean(), "handle");
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "handle");
|
||||
serviceActivator.setOutputChannel(targetChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, sourceChannel);
|
||||
context.getBeanFactory().registerSingleton("testEndpoint", endpoint);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<constructor-arg ref="sourceChannel"/>
|
||||
</bean>
|
||||
|
||||
<bean id="serviceActivator" class="org.springframework.integration.endpoint.ServiceActivatorEndpoint">
|
||||
<bean id="serviceActivator" class="org.springframework.integration.endpoint.ServiceActivatingConsumer">
|
||||
<constructor-arg ref="handler"/>
|
||||
<property name="outputChannel" ref="targetChannel"/>
|
||||
</bean>
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.endpoint.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.endpoint.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
@@ -45,7 +45,7 @@ public class SimpleDispatcherTests {
|
||||
public void singleMessage() throws InterruptedException {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
dispatcher.addConsumer(createEndpoint(TestHandlers.countDownHandler(latch)));
|
||||
dispatcher.addConsumer(createConsumer(TestHandlers.countDownHandler(latch)));
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
latch.await(500, TimeUnit.MILLISECONDS);
|
||||
assertEquals(0, latch.getCount());
|
||||
@@ -57,8 +57,8 @@ public class SimpleDispatcherTests {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicInteger counter1 = new AtomicInteger();
|
||||
final AtomicInteger counter2 = new AtomicInteger();
|
||||
dispatcher.addConsumer(createEndpoint(TestHandlers.countingCountDownHandler(counter1, latch)));
|
||||
dispatcher.addConsumer(createEndpoint(TestHandlers.countingCountDownHandler(counter2, latch)));
|
||||
dispatcher.addConsumer(createConsumer(TestHandlers.countingCountDownHandler(counter1, latch)));
|
||||
dispatcher.addConsumer(createConsumer(TestHandlers.countingCountDownHandler(counter2, latch)));
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
latch.await(500, TimeUnit.MILLISECONDS);
|
||||
assertEquals(0, latch.getCount());
|
||||
@@ -161,21 +161,21 @@ public class SimpleDispatcherTests {
|
||||
final AtomicInteger counter2 = new AtomicInteger();
|
||||
final AtomicInteger counter3 = new AtomicInteger();
|
||||
final AtomicInteger selectorCounter = new AtomicInteger();
|
||||
AbstractReplyProducingMessageConsumer endpoint1 = createEndpoint(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageConsumer endpoint2 = createEndpoint(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageConsumer endpoint3 = createEndpoint(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
endpoint1.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
endpoint2.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
endpoint3.setSelector(new TestMessageSelector(selectorCounter, true));
|
||||
dispatcher.addConsumer(endpoint1);
|
||||
dispatcher.addConsumer(endpoint2);
|
||||
dispatcher.addConsumer(endpoint3);
|
||||
AbstractReplyProducingMessageConsumer consumer1 = createConsumer(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer2 = createConsumer(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer3 = createConsumer(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
consumer1.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer2.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer3.setSelector(new TestMessageSelector(selectorCounter, true));
|
||||
dispatcher.addConsumer(consumer1);
|
||||
dispatcher.addConsumer(consumer2);
|
||||
dispatcher.addConsumer(consumer3);
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
assertEquals(0, latch.getCount());
|
||||
assertEquals("selectors should have been invoked one time each", 3, selectorCounter.get());
|
||||
assertEquals("handler with rejecting selector should not have received the message", 0, counter1.get());
|
||||
assertEquals("handler with rejecting selector should not have received the message", 0, counter2.get());
|
||||
assertEquals("handler with accepting selector should have received the message", 1, counter3.get());
|
||||
assertEquals("consumer with rejecting selector should not have received the message", 0, counter1.get());
|
||||
assertEquals("consumer with rejecting selector should not have received the message", 0, counter2.get());
|
||||
assertEquals("consumer with accepting selector should have received the message", 1, counter3.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,15 +186,15 @@ public class SimpleDispatcherTests {
|
||||
final AtomicInteger counter2 = new AtomicInteger();
|
||||
final AtomicInteger counter3 = new AtomicInteger();
|
||||
final AtomicInteger selectorCounter = new AtomicInteger();
|
||||
AbstractReplyProducingMessageConsumer endpoint1 = createEndpoint(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageConsumer endpoint2 = createEndpoint(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageConsumer endpoint3 = createEndpoint(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
endpoint1.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
endpoint2.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
endpoint3.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
dispatcher.addConsumer(endpoint1);
|
||||
dispatcher.addConsumer(endpoint2);
|
||||
dispatcher.addConsumer(endpoint3);
|
||||
AbstractReplyProducingMessageConsumer consumer1 = createConsumer(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer2 = createConsumer(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer3 = createConsumer(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
consumer1.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer2.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer3.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
dispatcher.addConsumer(consumer1);
|
||||
dispatcher.addConsumer(consumer2);
|
||||
dispatcher.addConsumer(consumer3);
|
||||
boolean exceptionThrown = false;
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
@@ -204,9 +204,9 @@ public class SimpleDispatcherTests {
|
||||
}
|
||||
assertTrue(exceptionThrown);
|
||||
assertEquals("selectors should have been invoked one time each", 3, selectorCounter.get());
|
||||
assertEquals("handler with rejecting selector should not have received the message", 0, counter1.get());
|
||||
assertEquals("handler with rejecting selector should not have received the message", 0, counter2.get());
|
||||
assertEquals("handler with rejecting selector should not have received the message", 0, counter3.get());
|
||||
assertEquals("consumer with rejecting selector should not have received the message", 0, counter1.get());
|
||||
assertEquals("consumer with rejecting selector should not have received the message", 0, counter2.get());
|
||||
assertEquals("consumer with rejecting selector should not have received the message", 0, counter3.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -257,8 +257,8 @@ public class SimpleDispatcherTests {
|
||||
}
|
||||
|
||||
|
||||
private static ServiceActivatorEndpoint createEndpoint(Object handler) {
|
||||
return new ServiceActivatorEndpoint(handler);
|
||||
private static ServiceActivatingConsumer createConsumer(Object object) {
|
||||
return new ServiceActivatingConsumer(object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CorrelationIdTests {
|
||||
.setCorrelationId(correlationId).build();
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint serviceActivator = new ServiceActivatorEndpoint(new TestBean(), "upperCase");
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "upperCase");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
endpoint.start();
|
||||
@@ -56,7 +56,7 @@ public class CorrelationIdTests {
|
||||
.setCorrelationId("correlationId").build();
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint serviceActivator = new ServiceActivatorEndpoint(new TestBean(), "upperCase");
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "upperCase");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
endpoint.start();
|
||||
@@ -73,7 +73,7 @@ public class CorrelationIdTests {
|
||||
.setCorrelationId(correlationId).build();
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint serviceActivator = new ServiceActivatorEndpoint(new TestBean(), "createMessage");
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "createMessage");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
endpoint.start();
|
||||
@@ -87,7 +87,7 @@ public class CorrelationIdTests {
|
||||
Message<?> message = new StringMessage("test");
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint serviceActivator = new ServiceActivatorEndpoint(new TestBean(), "createMessage");
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "createMessage");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
endpoint.start();
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void outputChannel() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = this.createEndpoint();
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
endpoint.setOutputChannel(channel);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").build();
|
||||
endpoint.onMessage(message);
|
||||
@@ -62,7 +62,7 @@ public class ServiceActivatorEndpointTests {
|
||||
public void outputChannelTakesPrecedence() {
|
||||
QueueChannel channel1 = new QueueChannel(1);
|
||||
QueueChannel channel2 = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = this.createEndpoint();
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
endpoint.setOutputChannel(channel1);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setReturnAddress(channel2).build();
|
||||
endpoint.onMessage(message);
|
||||
@@ -76,7 +76,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void returnAddressHeader() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = this.createEndpoint();
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setReturnAddress(channel).build();
|
||||
endpoint.onMessage(message);
|
||||
Message<?> reply = channel.receive(0);
|
||||
@@ -90,7 +90,7 @@ public class ServiceActivatorEndpointTests {
|
||||
channel.setBeanName("testChannel");
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
channelResolver.addChannel(channel);
|
||||
ServiceActivatorEndpoint endpoint = this.createEndpoint();
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
endpoint.setChannelResolver(channelResolver);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setReturnAddress("testChannel").build();
|
||||
endpoint.onMessage(message);
|
||||
@@ -110,7 +110,7 @@ public class ServiceActivatorEndpointTests {
|
||||
return new StringMessage("foo" + message.getPayload());
|
||||
}
|
||||
};
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(handler, "handle");
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(handler, "handle");
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
channelResolver.addChannel(replyChannel2);
|
||||
endpoint.setChannelResolver(channelResolver);
|
||||
@@ -135,7 +135,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void noOutputChannelFallsBackToReturnAddress() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = this.createEndpoint();
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setReturnAddress(channel).build();
|
||||
endpoint.onMessage(message);
|
||||
Message<?> reply = channel.receive(0);
|
||||
@@ -145,7 +145,7 @@ public class ServiceActivatorEndpointTests {
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
public void noReplyTarget() {
|
||||
ServiceActivatorEndpoint endpoint = this.createEndpoint();
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
Message<?> message = MessageBuilder.withPayload("foo").build();
|
||||
endpoint.onMessage(message);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void noReplyMessage() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
new TestNullReplyBean(), "handle");
|
||||
endpoint.setOutputChannel(channel);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").build();
|
||||
@@ -164,7 +164,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
public void noReplyMessageWithRequiresReply() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
new TestNullReplyBean(), "handle");
|
||||
endpoint.setRequiresReply(true);
|
||||
endpoint.setOutputChannel(channel);
|
||||
@@ -174,7 +174,7 @@ public class ServiceActivatorEndpointTests {
|
||||
|
||||
@Test(expected=MessageRejectedException.class)
|
||||
public void endpointWithSelectorRejecting() {
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
TestHandlers.nullHandler(), "handle");
|
||||
endpoint.setSelector(new MessageSelector() {
|
||||
public boolean accept(Message<?> message) {
|
||||
@@ -187,7 +187,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void endpointWithSelectorAccepting() throws InterruptedException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
TestHandlers.countDownHandler(latch), "handle");
|
||||
endpoint.setSelector(new MessageSelector() {
|
||||
public boolean accept(Message<?> message) {
|
||||
@@ -202,7 +202,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void endpointWithMultipleSelectorsAndFirstRejects() {
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
TestHandlers.countingHandler(counter), "handle");
|
||||
MessageSelectorChain selectorChain = new MessageSelectorChain();
|
||||
selectorChain.add(new MessageSelector() {
|
||||
@@ -233,7 +233,7 @@ public class ServiceActivatorEndpointTests {
|
||||
public void endpointWithMultipleSelectorsAndFirstAccepts() {
|
||||
final AtomicInteger selectorCounter = new AtomicInteger();
|
||||
AtomicInteger handlerCounter = new AtomicInteger();
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
TestHandlers.countingHandler(handlerCounter), "handle");
|
||||
MessageSelectorChain selectorChain = new MessageSelectorChain();
|
||||
selectorChain.add(new MessageSelector() {
|
||||
@@ -264,7 +264,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void endpointWithMultipleSelectorsAndBothAccept() {
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
TestHandlers.countingHandler(counter), "handle");
|
||||
MessageSelectorChain selectorChain = new MessageSelectorChain();
|
||||
selectorChain.add(new MessageSelector() {
|
||||
@@ -287,7 +287,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void correlationIdNotSetIfMessageIsReturnedUnaltered() {
|
||||
QueueChannel replyChannel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(new Object() {
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return message;
|
||||
@@ -303,7 +303,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void correlationIdSetByHandlerTakesPrecedence() {
|
||||
QueueChannel replyChannel = new QueueChannel(1);
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(new Object() {
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return MessageBuilder.fromMessage(message)
|
||||
@@ -320,8 +320,8 @@ public class ServiceActivatorEndpointTests {
|
||||
}
|
||||
|
||||
|
||||
private ServiceActivatorEndpoint createEndpoint() {
|
||||
return new ServiceActivatorEndpoint(new TestBean(), "handle");
|
||||
private ServiceActivatingConsumer createEndpoint() {
|
||||
return new ServiceActivatingConsumer(new TestBean(), "handle");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ServiceActivatorMethodResolutionTests {
|
||||
@Test
|
||||
public void singleAnnotationMatches() {
|
||||
SingleAnnotationTestBean testBean = new SingleAnnotationTestBean();
|
||||
ServiceActivatorEndpoint serviceActivator = new ServiceActivatorEndpoint(testBean);
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(testBean);
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
serviceActivator.onMessage(new StringMessage("foo"));
|
||||
@@ -44,13 +44,13 @@ public class ServiceActivatorMethodResolutionTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void multipleAnnotationFails() {
|
||||
MultipleAnnotationTestBean testBean = new MultipleAnnotationTestBean();
|
||||
new ServiceActivatorEndpoint(testBean);
|
||||
new ServiceActivatingConsumer(testBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singlePublicMethodMatches() {
|
||||
SinglePublicMethodTestBean testBean = new SinglePublicMethodTestBean();
|
||||
ServiceActivatorEndpoint serviceActivator = new ServiceActivatorEndpoint(testBean);
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(testBean);
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
serviceActivator.onMessage(new StringMessage("foo"));
|
||||
@@ -61,7 +61,7 @@ public class ServiceActivatorMethodResolutionTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void multiplePublicMethodFails() {
|
||||
MultiplePublicMethodTestBean testBean = new MultiplePublicMethodTestBean();
|
||||
new ServiceActivatorEndpoint(testBean);
|
||||
new ServiceActivatingConsumer(testBean);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.endpoint.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DefaultMethodResolverTests {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(testBean);
|
||||
proxyFactory.setProxyTargetClass(false);
|
||||
testBean = (GreetingService) proxyFactory.getProxy();
|
||||
ServiceActivatorEndpoint consumer = new ServiceActivatorEndpoint(testBean);
|
||||
ServiceActivatingConsumer consumer = new ServiceActivatingConsumer(testBean);
|
||||
consumer.setOutputChannel(output);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(consumer, input);
|
||||
endpoint.start();
|
||||
@@ -98,7 +98,7 @@ public class DefaultMethodResolverTests {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(testBean);
|
||||
proxyFactory.setProxyTargetClass(true);
|
||||
testBean = (GreetingService) proxyFactory.getProxy();
|
||||
ServiceActivatorEndpoint consumer = new ServiceActivatorEndpoint(testBean);
|
||||
ServiceActivatingConsumer consumer = new ServiceActivatingConsumer(testBean);
|
||||
consumer.setOutputChannel(output);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(consumer, input);
|
||||
endpoint.start();
|
||||
|
||||
Reference in New Issue
Block a user