Renamed Source to MessageSource.

This commit is contained in:
Mark Fisher
2008-06-30 22:57:23 +00:00
parent 07b2179baa
commit 5235537c80
17 changed files with 39 additions and 40 deletions

View File

@@ -30,7 +30,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.bus.MessageBus;
import org.springframework.integration.channel.ChannelRegistryAware;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.Target;
import org.springframework.util.Assert;
@@ -65,7 +65,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Init
public void afterPropertiesSet() {
this.postProcessors.put(MessageHandler.class, new HandlerAnnotationPostProcessor(this.messageBus, this.beanClassLoader));
this.postProcessors.put(Source.class, new SourceAnnotationPostProcessor(this.messageBus, this.beanClassLoader));
this.postProcessors.put(MessageSource.class, new SourceAnnotationPostProcessor(this.messageBus, this.beanClassLoader));
this.postProcessors.put(Target.class, new TargetAnnotationPostProcessor(this.messageBus, this.beanClassLoader));
}

View File

@@ -22,7 +22,6 @@ import java.util.List;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.annotation.MessageSource;
import org.springframework.integration.annotation.Polled;
import org.springframework.integration.bus.MessageBus;
import org.springframework.integration.channel.MessageChannel;
@@ -30,7 +29,7 @@ import org.springframework.integration.dispatcher.DirectChannel;
import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.endpoint.SourceEndpoint;
import org.springframework.integration.message.MethodInvokingSource;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.scheduling.PollingSchedule;
import org.springframework.util.StringUtils;
@@ -39,21 +38,21 @@ import org.springframework.util.StringUtils;
*
* @author Mark Fisher
*/
public class SourceAnnotationPostProcessor extends AbstractAnnotationMethodPostProcessor<Source<?>> {
public class SourceAnnotationPostProcessor extends AbstractAnnotationMethodPostProcessor<MessageSource<?>> {
public SourceAnnotationPostProcessor(MessageBus messageBus, ClassLoader beanClassLoader) {
super(MessageSource.class, messageBus, beanClassLoader);
super(org.springframework.integration.annotation.MessageSource.class, messageBus, beanClassLoader);
}
protected Source<?> processMethod(Object bean, Method method, Annotation annotation) {
protected MessageSource<?> processMethod(Object bean, Method method, Annotation annotation) {
MethodInvokingSource source = new MethodInvokingSource();
source.setObject(bean);
source.setMethod(method.getName());
return source;
}
protected Source<?> processResults(List<Source<?>> results) {
protected MessageSource<?> processResults(List<MessageSource<?>> results) {
if (results.size() > 1) {
throw new ConfigurationException("At most one @MessageSource annotation is allowed per class.");
}
@@ -76,7 +75,7 @@ public class SourceAnnotationPostProcessor extends AbstractAnnotationMethodPostP
outputChannel = new DirectChannel();
this.getMessageBus().registerChannel(beanName + ".output", outputChannel);
}
SourceEndpoint endpoint = new SourceEndpoint((Source<?>) bean, outputChannel);
SourceEndpoint endpoint = new SourceEndpoint((MessageSource<?>) bean, outputChannel);
endpoint.setSchedule(schedule);
return endpoint;
}

View File

@@ -24,7 +24,7 @@ import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.channel.DispatcherPolicy;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.Subscribable;
import org.springframework.integration.message.Target;
import org.springframework.integration.message.selector.MessageSelector;
@@ -32,7 +32,7 @@ import org.springframework.integration.message.selector.MessageSelector;
/**
* A channel that invokes the subscribed {@link MessageHandler handler(s)} in a
* sender's thread (returning after at most one handles the message). If a
* {@link Source} is provided, then that source will likewise be polled
* {@link MessageSource} is provided, then that source will likewise be polled
* within a receiver's thread.
*
* @author Dave Syer
@@ -40,7 +40,7 @@ import org.springframework.integration.message.selector.MessageSelector;
*/
public class DirectChannel extends AbstractMessageChannel implements Subscribable {
private volatile Source<?> source;
private volatile MessageSource<?> source;
private final SimpleDispatcher dispatcher;
@@ -51,7 +51,7 @@ public class DirectChannel extends AbstractMessageChannel implements Subscribabl
this(null);
}
public DirectChannel(Source<?> source) {
public DirectChannel(MessageSource<?> source) {
super(defaultDispatcherPolicy());
this.source = source;
this.dispatcher = new SimpleDispatcher(this.getDispatcherPolicy());

View File

@@ -23,26 +23,26 @@ import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageDeliveryAware;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.PollCommand;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.scheduling.Schedule;
import org.springframework.util.Assert;
/**
* A channel adapter that retrieves messages from a {@link Source}
* A channel adapter that retrieves messages from a {@link MessageSource}
* and then sends the resulting messages to the provided {@link MessageChannel}.
*
* @author Mark Fisher
*/
public class SourceEndpoint extends AbstractEndpoint {
private final Source<?> source;
private final MessageSource<?> source;
private final SimpleDispatcher dispatcher = new SimpleDispatcher(new DispatcherPolicy());
private volatile Schedule schedule;
public SourceEndpoint(Source<?> source, MessageChannel channel) {
public SourceEndpoint(MessageSource<?> source, MessageChannel channel) {
Assert.notNull(source, "source must not be null");
Assert.notNull(channel, "channel must not be null");
this.source = source;

View File

@@ -21,7 +21,7 @@ package org.springframework.integration.message;
*
* @author Mark Fisher
*/
public interface BlockingSource<T> extends Source<T> {
public interface BlockingSource<T> extends MessageSource<T> {
/**
* Receive a message, blocking indefinitely if necessary.

View File

@@ -21,7 +21,7 @@ package org.springframework.integration.message;
*
* @author Mark Fisher
*/
public interface Source<T> {
public interface MessageSource<T> {
/**
* Retrieve a message from this source or <code>null</code> if no message is available.

View File

@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
*
* @author Mark Fisher
*/
public class MethodInvokingSource implements Source<Object>, InitializingBean {
public class MethodInvokingSource implements MessageSource<Object>, InitializingBean {
private Object object;

View File

@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
import org.springframework.util.Assert;
/**
* Scheduling metadata for a polling task.
* Scheduling metadata for a task that repeats at a regular interval.
*
* @author Mark Fisher
*/

View File

@@ -39,7 +39,7 @@ import org.springframework.integration.message.ErrorMessage;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.scheduling.PollingSchedule;
import org.springframework.integration.scheduling.Subscription;
@@ -258,7 +258,7 @@ public class MessageBusTests {
assertTrue(messageBusAwareBean.getMessageBus() == context.getBean("bus"));
}
private static class FailingSource implements Source<Object> {
private static class FailingSource implements MessageSource<Object> {
private CountDownLatch latch;

View File

@@ -17,13 +17,13 @@
package org.springframework.integration.config;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.StringMessage;
/**
* @author Mark Fisher
*/
public class TestSource implements Source {
public class TestSource implements MessageSource {
public Message<?> receive() {
return new StringMessage("test");

View File

@@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.message.Target;
@@ -68,7 +68,7 @@ public class DirectChannelTests {
@Test
public void testReceive() {
DirectChannel channel = new DirectChannel(new Source<String>() {
DirectChannel channel = new DirectChannel(new MessageSource<String>() {
public Message<String> receive() {
return new StringMessage("foo");
}
@@ -147,7 +147,7 @@ public class DirectChannelTests {
}
private static class MessageReturningTestSource implements Source<String> {
private static class MessageReturningTestSource implements MessageSource<String> {
private final String messageText;

View File

@@ -28,7 +28,7 @@ import org.springframework.integration.message.CommandMessage;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.PollCommand;
import org.springframework.integration.message.Source;
import org.springframework.integration.message.MessageSource;
/**
* @author Mark Fisher
@@ -47,7 +47,7 @@ public class SourceEndpointTests {
}
private static class TestSource implements Source<String> {
private static class TestSource implements MessageSource<String> {
private String message;