public SimpleRSSFeedFetcher() { this.feedInfoCache = HashMapFeedInfoCache.getInstance(); }
/** * Get the global instance of the cache * * @return an implementation of FeedFetcherCache */ public static synchronized FeedFetcherCache getInstance() { if (instance == null) { instance = new HashMapFeedInfoCache(); } return instance; }
/** * <p> * Constructor for HashMapFeedInfoCache * </p> * * <p> * Only use this if you want multiple instances of the cache. Usually getInstance() is more * appropriate. * </p> * */ public HashMapFeedInfoCache() { setInfoCache(createInfoCache()); }
protected Object get(final Object key) { return getInfoCache().get(key); }
/** * @see extensions.io.FeedFetcherCache#getFeedInfo(java.net.URL) */ @Override public SyndFeedInfo getFeedInfo(final URL feedUrl) { return (SyndFeedInfo) get(feedUrl.toString()); }
/** * @see extensions.io.FeedFetcherCache#setFeedInfo(java.net.URL, extensions.io.SyndFeedInfo) */ @Override public void setFeedInfo(final URL feedUrl, final SyndFeedInfo syndFeedInfo) { put(feedUrl.toString(), syndFeedInfo); }
protected void put(final String key, final SyndFeedInfo value) { getInfoCache().put(key, value); }
public RSSRecordReader(String url) throws MalformedURLException { feedUrl = new URL(url); feedInfoCache = HashMapFeedInfoCache.getInstance(); fetcher = new HttpURLFeedFetcher(feedInfoCache); listener = new FetcherEventListenerImpl(this, LOGGER); fetcher.addFetcherEventListener(listener); }
@Override public Set<AggregateFeed> fetchAggregateFeeds(Set<AggregateFeed> aggregateFeeds) { ArrayList<Future<?>> futureList = new ArrayList<Future<?>>(); for (AggregateFeed aggregate : aggregateFeeds) { for (FeedChannel channel : aggregate.getChannels()) { Runnable task = componentProvider.newInstance(getFeedChannelFetchTaskClass(), new MgnlHttpURLFeedFetcher(HashMapFeedInfoCache.getInstance()), channel, aggregate.getName()); Future<?> future = executorService.submit(task); futureList.add(future); } } // Each Future will block on get() when not done, thus ensuring this method will return only when all // attempts to fetch feed aggregates have completed. for (Future<?> future : futureList) { waitForFutureResult(future); } return aggregateFeeds; }