Removed the @MessageSource method-level annotation and added @Pollable as its replacement. Also added the @ChannelAdapter class-level annotation (refactoring to remove SourceEndpoint).

This commit is contained in:
Mark Fisher
2008-08-05 20:02:52 +00:00
parent bbd7a12a4e
commit 8274dfc428
10 changed files with 105 additions and 92 deletions

View File

@@ -39,11 +39,12 @@ import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.annotation.ChannelAdapter;
import org.springframework.integration.annotation.Concurrency;
import org.springframework.integration.annotation.Handler;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.MessageSource;
import org.springframework.integration.annotation.MessageTarget;
import org.springframework.integration.annotation.Pollable;
import org.springframework.integration.annotation.Polled;
import org.springframework.integration.annotation.Splitter;
import org.springframework.integration.annotation.Transformer;
@@ -373,15 +374,14 @@ public class MessagingAnnotationPostProcessorTests {
}
@Test
public void testMessageSourceAnnotation() {
public void testChannelAdapterAnnotation() {
MessageBus messageBus = new DefaultMessageBus();
QueueChannel testChannel = new QueueChannel();
messageBus.registerChannel("testChannel", testChannel);
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(messageBus);
postProcessor.afterPropertiesSet();
MessageSourceAnnotationTestBean testBean = new MessageSourceAnnotationTestBean();
ChannelAdapterAnnotationTestBean testBean = new ChannelAdapterAnnotationTestBean();
postProcessor.postProcessAfterInitialization(testBean, "testBean");
messageBus.start();
PollableChannel testChannel = (PollableChannel) messageBus.lookupChannel("testChannel");
Message<?> message = testChannel.receive(1000);
assertEquals("test", message.getPayload());
messageBus.stop();
@@ -526,11 +526,10 @@ public class MessagingAnnotationPostProcessorTests {
}
@MessageEndpoint(output="testChannel")
@Polled(period=100)
private static class MessageSourceAnnotationTestBean {
@ChannelAdapter("testChannel")
private static class ChannelAdapterAnnotationTestBean {
@MessageSource
@Pollable
public String test() {
return "test";
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.endpoint.annotation;
import org.springframework.integration.annotation.Handler;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.Polled;
import org.springframework.integration.annotation.MessageSource;
/**
* @author Mark Fisher
*/
@MessageEndpoint(output="outputChannel")
@Polled(period=100)
public class InboundChannelAdapterTestBean {
@MessageSource
public String getName() {
return "world";
}
@Handler
public String sayHello(String name) {
return "hello " + name;
}
}