diff --git a/org.springframework.integration.file/src/main/java/org/springframework/integration/file/PollableFileSource.java b/org.springframework.integration.file/src/main/java/org/springframework/integration/file/PollableFileSource.java index 4d6c34c817..9d5ce8f582 100644 --- a/org.springframework.integration.file/src/main/java/org/springframework/integration/file/PollableFileSource.java +++ b/org.springframework.integration.file/src/main/java/org/springframework/integration/file/PollableFileSource.java @@ -32,8 +32,8 @@ import org.springframework.core.io.Resource; import org.springframework.integration.message.GenericMessage; import org.springframework.integration.message.Message; import org.springframework.integration.message.MessageDeliveryAware; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.MessagingException; -import org.springframework.integration.message.PollableSource; import org.springframework.util.Assert; /** @@ -52,7 +52,7 @@ import org.springframework.util.Assert; * * @author Iwein Fuld */ -public class PollableFileSource implements PollableSource, MessageDeliveryAware { +public class PollableFileSource implements MessageSource, MessageDeliveryAware { private static final Log logger = LogFactory.getLog(PollableFileSource.class); diff --git a/org.springframework.integration.ftp/src/main/java/org/springframework/integration/ftp/AbstractDirectorySource.java b/org.springframework.integration.ftp/src/main/java/org/springframework/integration/ftp/AbstractDirectorySource.java index 393c24467f..e22b439021 100644 --- a/org.springframework.integration.ftp/src/main/java/org/springframework/integration/ftp/AbstractDirectorySource.java +++ b/org.springframework.integration.ftp/src/main/java/org/springframework/integration/ftp/AbstractDirectorySource.java @@ -27,8 +27,8 @@ import org.apache.commons.logging.LogFactory; import org.springframework.integration.message.Message; import org.springframework.integration.message.MessageBuilder; import org.springframework.integration.message.MessageDeliveryAware; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.MessagingException; -import org.springframework.integration.message.PollableSource; /** * Base class for implementing a PollableSource that creates messages from files @@ -37,7 +37,7 @@ import org.springframework.integration.message.PollableSource; * @author Marius Bogoevici * @author Iwein Fuld */ -public abstract class AbstractDirectorySource implements PollableSource, MessageDeliveryAware { +public abstract class AbstractDirectorySource implements MessageSource, MessageDeliveryAware { public final static String FILE_INFO_PROPERTY = "file.info"; diff --git a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsSource.java b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsSource.java index 93a224233e..c343d7c039 100644 --- a/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsSource.java +++ b/org.springframework.integration.jms/src/main/java/org/springframework/integration/jms/JmsSource.java @@ -21,7 +21,7 @@ import javax.jms.Destination; import org.springframework.integration.message.GenericMessage; import org.springframework.integration.message.Message; -import org.springframework.integration.message.PollableSource; +import org.springframework.integration.message.MessageSource; import org.springframework.jms.core.JmsTemplate; /** @@ -32,7 +32,7 @@ import org.springframework.jms.core.JmsTemplate; * * @author Mark Fisher */ -public class JmsSource extends AbstractJmsTemplateBasedAdapter implements PollableSource { +public class JmsSource extends AbstractJmsTemplateBasedAdapter implements MessageSource { public JmsSource(JmsTemplate jmsTemplate) { super(jmsTemplate); diff --git a/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/PollingMailSource.java b/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/PollingMailSource.java index 4a67eefda3..61882ade6b 100644 --- a/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/PollingMailSource.java +++ b/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/PollingMailSource.java @@ -27,7 +27,6 @@ import org.springframework.integration.message.Message; import org.springframework.integration.message.MessageBuilder; import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.MessagingException; -import org.springframework.integration.message.PollableSource; import org.springframework.util.Assert; /** @@ -38,7 +37,7 @@ import org.springframework.util.Assert; * @author Jonas Partner * @author Mark Fisher */ -public class PollingMailSource implements PollableSource { +public class PollingMailSource implements MessageSource { private final Log logger = LogFactory.getLog(this.getClass()); diff --git a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamSource.java b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamSource.java index b60b47c983..0b87499bee 100644 --- a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamSource.java +++ b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamSource.java @@ -22,15 +22,15 @@ import java.io.InputStream; import org.springframework.integration.message.GenericMessage; import org.springframework.integration.message.Message; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.MessagingException; -import org.springframework.integration.message.PollableSource; /** * A pollable source for receiving bytes from an {@link InputStream}. * * @author Mark Fisher */ -public class ByteStreamSource implements PollableSource { +public class ByteStreamSource implements MessageSource { private BufferedInputStream stream; diff --git a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamSource.java b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamSource.java index 4172888e11..15f3e33440 100644 --- a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamSource.java +++ b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamSource.java @@ -23,8 +23,8 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; import org.springframework.integration.ConfigurationException; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.MessagingException; -import org.springframework.integration.message.PollableSource; import org.springframework.integration.message.StringMessage; import org.springframework.util.Assert; @@ -33,7 +33,7 @@ import org.springframework.util.Assert; * * @author Mark Fisher */ -public class CharacterStreamSource implements PollableSource { +public class CharacterStreamSource implements MessageSource { private final BufferedReader reader; diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParserTests.java b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParserTests.java index 16d47a4759..93d215badd 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParserTests.java +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParserTests.java @@ -35,7 +35,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.ConfigurationException; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.message.Message; -import org.springframework.integration.message.PollableSource; +import org.springframework.integration.message.MessageSource; /** * @author Mark Fisher @@ -54,7 +54,7 @@ public class ConsoleInboundChannelAdapterParserTests { "consoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class); SourcePollingChannelAdapter adapter = (SourcePollingChannelAdapter) context.getBean("adapterWithDefaultCharset.adapter"); - PollableSource source = (PollableSource) new DirectFieldAccessor(adapter).getPropertyValue("source"); + MessageSource source = (MessageSource) new DirectFieldAccessor(adapter).getPropertyValue("source"); DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(source); Reader bufferedReader = (Reader) sourceAccessor.getPropertyValue("reader"); assertEquals(BufferedReader.class, bufferedReader.getClass()); @@ -74,7 +74,7 @@ public class ConsoleInboundChannelAdapterParserTests { "consoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class); SourcePollingChannelAdapter adapter = (SourcePollingChannelAdapter) context.getBean("adapterWithProvidedCharset.adapter"); - PollableSource source = (PollableSource) new DirectFieldAccessor(adapter).getPropertyValue("source"); + MessageSource source = (MessageSource) new DirectFieldAccessor(adapter).getPropertyValue("source"); DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(source); Reader bufferedReader = (Reader) sourceAccessor.getPropertyValue("reader"); assertEquals(BufferedReader.class, bufferedReader.getClass()); diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePoller.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePoller.java index 2baeeee276..a0510db77f 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePoller.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePoller.java @@ -21,8 +21,8 @@ import org.springframework.integration.message.BlockingSource; import org.springframework.integration.message.Message; import org.springframework.integration.message.MessageDeliveryAware; import org.springframework.integration.message.MessageDeliveryException; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.MessagingException; -import org.springframework.integration.message.PollableSource; import org.springframework.integration.scheduling.Trigger; import org.springframework.util.Assert; @@ -31,14 +31,14 @@ import org.springframework.util.Assert; */ public class SourcePoller extends AbstractPoller { - private final PollableSource source; + private final MessageSource source; private final MessageChannel channel; private volatile long receiveTimeout = 1000; - public SourcePoller(PollableSource source, MessageChannel channel, Trigger trigger) { + public SourcePoller(MessageSource source, MessageChannel channel, Trigger trigger) { super(trigger); Assert.notNull(source, "source must not be null"); Assert.notNull(channel, "channel must not be null"); diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java index 4efc314f8e..765de8826a 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java @@ -20,8 +20,8 @@ import java.util.concurrent.ScheduledFuture; import org.springframework.context.Lifecycle; import org.springframework.integration.channel.MessageChannel; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.MethodInvokingSource; -import org.springframework.integration.message.PollableSource; import org.springframework.integration.scheduling.TaskScheduler; import org.springframework.integration.scheduling.Trigger; @@ -34,7 +34,7 @@ import org.springframework.integration.scheduling.Trigger; */ public class SourcePollingChannelAdapter extends AbstractMessageProducingEndpoint implements Lifecycle { - private volatile PollableSource source; + private volatile MessageSource source; private volatile Trigger trigger; @@ -49,7 +49,7 @@ public class SourcePollingChannelAdapter extends AbstractMessageProducingEndpoin private final Object lifecycleMonitor = new Object(); - public void setSource(PollableSource source) { + public void setSource(MessageSource source) { this.source = source; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/message/BlockingSource.java b/org.springframework.integration/src/main/java/org/springframework/integration/message/BlockingSource.java index 83e726e702..c0b0484092 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/message/BlockingSource.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/message/BlockingSource.java @@ -21,7 +21,7 @@ package org.springframework.integration.message; * * @author Mark Fisher */ -public interface BlockingSource extends PollableSource { +public interface BlockingSource extends MessageSource { /** * Receive a message, blocking indefinitely if necessary. diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageSource.java b/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageSource.java index 8070d77cf7..347c9ddbe9 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageSource.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageSource.java @@ -17,10 +17,16 @@ package org.springframework.integration.message; /** - * Base interface for any source of {@link Message Messages}. + * Base interface for any source of {@link Message Messages} that can be polled. * * @author Mark Fisher */ public interface MessageSource { + /** + * Retrieve the next available message from this source. + * Returns null if no message is available. + */ + Message receive(); + } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/message/MethodInvokingSource.java b/org.springframework.integration/src/main/java/org/springframework/integration/message/MethodInvokingSource.java index 84b01d1bff..f734d53e1f 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/message/MethodInvokingSource.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/message/MethodInvokingSource.java @@ -33,7 +33,7 @@ import org.springframework.util.Assert; * * @author Mark Fisher */ -public class MethodInvokingSource implements PollableSource, InitializingBean { +public class MethodInvokingSource implements MessageSource, InitializingBean { private volatile Object object; diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/message/PollableSource.java b/org.springframework.integration/src/main/java/org/springframework/integration/message/PollableSource.java deleted file mode 100644 index df9c5f7d24..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/message/PollableSource.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2002-2008 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.message; - -/** - * Base interface for any source of {@link Message Messages} that can be polled. - * - * @author Mark Fisher - */ -public interface PollableSource extends MessageSource { - - /** - * Retrieve a message from this source or null if no message is available. - */ - Message receive(); - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java index 44f133d322..569e610d96 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java @@ -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.MessageBuilder; -import org.springframework.integration.message.PollableSource; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.StringMessage; import org.springframework.integration.scheduling.IntervalTrigger; @@ -269,7 +269,7 @@ public class DefaultMessageBusTests { } - private static class FailingSource implements PollableSource { + private static class FailingSource implements MessageSource { private CountDownLatch latch; diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestPollableSource.java b/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestPollableSource.java deleted file mode 100644 index 08f5317940..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestPollableSource.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2002-2008 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.channel.config; - -import org.springframework.integration.message.Message; -import org.springframework.integration.message.PollableSource; -import org.springframework.integration.message.StringMessage; - -/** - * @author Mark Fisher - */ -public class TestPollableSource implements PollableSource { - - public Message receive() { - return new StringMessage("test"); - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSource.java b/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSource.java index ad5d36af84..6ed3aa5a0a 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSource.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSource.java @@ -17,13 +17,13 @@ package org.springframework.integration.channel.config; import org.springframework.integration.message.Message; -import org.springframework.integration.message.PollableSource; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.StringMessage; /** * @author Mark Fisher */ -public class TestSource implements PollableSource { +public class TestSource implements MessageSource { private final String text; 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 deleted file mode 100644 index 253caec3bb..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/channel/config/TestSubscribableSource.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2002-2008 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.channel.config; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.springframework.integration.message.Message; -import org.springframework.integration.message.MessageConsumer; -import org.springframework.integration.message.Subscribable; - -/** - * @author Mark Fisher - */ -public class TestSubscribableSource implements Subscribable { - - private final List subscibers = new CopyOnWriteArrayList(); - - - public boolean subscribe(MessageConsumer subsciber) { - return this.subscibers.add(subsciber); - } - - public boolean unsubscribe(MessageConsumer subsciber) { - return this.subscibers.remove(subsciber); - } - - public void publishMessage(Message message) { - for (MessageConsumer subsciber : this.subscibers) { - subsciber.onMessage(message); - } - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/TestSource.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/TestSource.java index e8da3a6006..88d965111f 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/TestSource.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/TestSource.java @@ -17,14 +17,14 @@ package org.springframework.integration.config; import org.springframework.integration.message.Message; -import org.springframework.integration.message.PollableSource; +import org.springframework.integration.message.MessageSource; import org.springframework.integration.message.StringMessage; /** * @author Mark Fisher */ @SuppressWarnings("unchecked") -public class TestSource implements PollableSource { +public class TestSource implements MessageSource { public Message receive() { return new StringMessage("test");