diff --git a/spring-integration-feed/src/main/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParser.java b/spring-integration-feed/src/main/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParser.java index 7e4b7c8ff2..c71a959827 100644 --- a/spring-integration-feed/src/main/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParser.java +++ b/spring-integration-feed/src/main/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParser.java @@ -38,7 +38,7 @@ public class FeedInboundChannelAdapterParser extends AbstractPollingInboundChann @Override protected BeanMetadataElement parseSource(final Element element, final ParserContext parserContext) { BeanDefinitionBuilder sourceBuilder = BeanDefinitionBuilder.genericBeanDefinition( - "org.springframework.integration.feed.FeedEntryMessageSource"); + "org.springframework.integration.feed.inbound.FeedEntryMessageSource"); sourceBuilder.addConstructorArgValue(element.getAttribute("url")); String feedFetcherRef = element.getAttribute("feed-fetcher"); if (StringUtils.hasText(feedFetcherRef)) { diff --git a/spring-integration-feed/src/main/java/org/springframework/integration/feed/FeedEntryMessageSource.java b/spring-integration-feed/src/main/java/org/springframework/integration/feed/inbound/FeedEntryMessageSource.java similarity index 90% rename from spring-integration-feed/src/main/java/org/springframework/integration/feed/FeedEntryMessageSource.java rename to spring-integration-feed/src/main/java/org/springframework/integration/feed/inbound/FeedEntryMessageSource.java index 102723871a..e77fe55fb4 100644 --- a/spring-integration-feed/src/main/java/org/springframework/integration/feed/FeedEntryMessageSource.java +++ b/spring-integration-feed/src/main/java/org/springframework/integration/feed/inbound/FeedEntryMessageSource.java @@ -14,11 +14,12 @@ * limitations under the License. */ -package org.springframework.integration.feed; +package org.springframework.integration.feed.inbound; import java.net.URL; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.List; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; @@ -73,7 +74,7 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements private final Object monitor = new Object(); - private final Comparator syndEntryComparator = new SyndEntryComparator(); + private final Comparator syndEntryComparator = new SyndEntryPublishedDateComparator(); private final Object feedMonitor = new Object(); @@ -211,10 +212,18 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements } - private static class SyndEntryComparator implements Comparator { + private static class SyndEntryPublishedDateComparator implements Comparator { public int compare(SyndEntry entry1, SyndEntry entry2) { - return entry1.getPublishedDate().compareTo(entry2.getPublishedDate()); + Date date1 = entry1.getPublishedDate(); + Date date2 = entry2.getPublishedDate(); + if (date1 != null && date2 != null) { + return date1.compareTo(date2); + } + if (date1 == null && date2 == null) { + return 0; + } + return (date2 == null) ? 1 : 0; } } @@ -227,14 +236,20 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements public void fetcherEvent(final FetcherEvent event) { String eventType = event.getEventType(); if (FetcherEvent.EVENT_TYPE_FEED_POLLED.equals(eventType)) { - logger.debug("\tEVENT: Feed Polled. URL = " + event.getUrlString()); + if (logger.isDebugEnabled()) { + logger.debug("\tEVENT: Feed Polled. URL = " + event.getUrlString()); + } } else if (FetcherEvent.EVENT_TYPE_FEED_RETRIEVED.equals(eventType)) { - logger.debug("\tEVENT: Feed Retrieved. URL = " + event.getUrlString()); + if (logger.isDebugEnabled()) { + logger.debug("\tEVENT: Feed Retrieved. URL = " + event.getUrlString()); + } feeds.add(event.getFeed()); } else if (FetcherEvent.EVENT_TYPE_FEED_UNCHANGED.equals(eventType)) { - logger.debug("\tEVENT: Feed Unchanged. URL = " + event.getUrlString()); + if (logger.isDebugEnabled()) { + logger.debug("\tEVENT: Feed Unchanged. URL = " + event.getUrlString()); + } } } } diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-context.xml b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-context.xml index 176b200724..03bbec7e75 100644 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-context.xml +++ b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-context.xml @@ -11,7 +11,7 @@ auto-startup="false" feed-fetcher="fileUrlFeedFetcher" metadata-store="customMetadataStore" - url="file:src/test/java/org/springframework/integration/feed/config/sample.rss"> + url="file:src/test/java/org/springframework/integration/feed/sample.rss"> @@ -19,7 +19,7 @@ - + diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-context.xml b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-context.xml index cd222f738f..d579ad9629 100644 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-context.xml +++ b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-context.xml @@ -10,7 +10,7 @@ @@ -19,7 +19,7 @@ - + diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-noid-context.xml b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-noid-context.xml index 842246bea9..411fb567e7 100644 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-noid-context.xml +++ b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests-file-usage-noid-context.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/integration/feed http://www.springframework.org/schema/integration/feed/spring-integration-feed-2.0.xsd"> @@ -16,6 +16,6 @@ - + \ No newline at end of file diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests.java b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests.java index 6329d313e5..cbae2bf856 100644 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests.java +++ b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/FeedInboundChannelAdapterParserTests.java @@ -40,7 +40,7 @@ import org.springframework.integration.MessagingException; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.core.MessageHandler; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; -import org.springframework.integration.feed.FeedEntryMessageSource; +import org.springframework.integration.feed.inbound.FeedEntryMessageSource; import org.springframework.integration.history.MessageHistory; import org.springframework.integration.store.MetadataStore; import org.springframework.integration.test.util.TestUtils; diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/sample.rss b/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/sample.rss deleted file mode 100644 index 31fa532a39..0000000000 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/config/sample.rss +++ /dev/null @@ -1,53 +0,0 @@ - - -Spring Integration -http://www.springsource.org/spring-integration - -Spring Integration is a really cool framework - -en-us -Copyright 2004-2010 SpringSource/VMWare -All Rights Reserved. -Tue, 12 Apr 2010 18:21:32 EST -240 - -http://www.springsource.org/sites/all/themes/dotorg09/images/dotorg09_logo.png -Spring Integration -http://www.springsource.org/spring-integration - - - - -Spring Integration adapters - -http://www.springsource.org/extensions/se-sia - -Spring Integration adapters are realy cool - -Tue, 23 Apr 2010 12:34:58 EST - - - - -Spring Integration download - -http://www.springsource.com/products/spring-community-download - -Download Spring Integration - -Sun, 13 Feb 2010 14:12:17 EST - - - - -Check out Spring Integration forums - -http://forum.springsource.org/forumdisplay.php?f=42 - -Spring Integration forums are awesome - -Wed, 13 Mar 2010 03:38:21 EST - - - - diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/FeedEntryMessageSourceTests.java b/spring-integration-feed/src/test/java/org/springframework/integration/feed/inbound/FeedEntryMessageSourceTests.java similarity index 98% rename from spring-integration-feed/src/test/java/org/springframework/integration/feed/FeedEntryMessageSourceTests.java rename to spring-integration-feed/src/test/java/org/springframework/integration/feed/inbound/FeedEntryMessageSourceTests.java index b9ccb2248e..2b43b0d9f5 100644 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/FeedEntryMessageSourceTests.java +++ b/spring-integration-feed/src/test/java/org/springframework/integration/feed/inbound/FeedEntryMessageSourceTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.integration.feed; +package org.springframework.integration.feed.inbound; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNull; @@ -27,6 +27,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.integration.Message; +import org.springframework.integration.feed.inbound.FeedEntryMessageSource; import org.springframework.integration.store.PropertiesPersistingMetadataStore; import com.sun.syndication.feed.synd.SyndEntry; diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/FileUrlFeedFetcher.java b/spring-integration-feed/src/test/java/org/springframework/integration/feed/inbound/FileUrlFeedFetcher.java similarity index 97% rename from spring-integration-feed/src/test/java/org/springframework/integration/feed/FileUrlFeedFetcher.java rename to spring-integration-feed/src/test/java/org/springframework/integration/feed/inbound/FileUrlFeedFetcher.java index d5a37e9305..2ef4f34b2f 100644 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/FileUrlFeedFetcher.java +++ b/spring-integration-feed/src/test/java/org/springframework/integration/feed/inbound/FileUrlFeedFetcher.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.integration.feed; +package org.springframework.integration.feed.inbound; import java.io.BufferedInputStream; import java.io.IOException; @@ -39,7 +39,7 @@ import com.sun.syndication.io.XmlReader; * @author Mark Fisher * @since 2.0 */ -public class FileUrlFeedFetcher extends AbstractFeedFetcher { +class FileUrlFeedFetcher extends AbstractFeedFetcher { /** * Retrieve a SyndFeed for the given URL.