当前位置: 首页>>代码示例>>Java>>正文


Java FeedFetcherCache类代码示例

本文整理汇总了Java中com.rometools.fetcher.impl.FeedFetcherCache的典型用法代码示例。如果您正苦于以下问题:Java FeedFetcherCache类的具体用法?Java FeedFetcherCache怎么用?Java FeedFetcherCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FeedFetcherCache类属于com.rometools.fetcher.impl包,在下文中一共展示了FeedFetcherCache类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFeed

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
private SyndFeed getFeed(String url) {
  FeedFetcherCache feedCache = HashMapFeedInfoCache.getInstance();
  try {
    HttpClientFeedFetcher httpClientFeedFetcher = new HttpClientFeedFetcher(feedCache);
    httpClientFeedFetcher.setConnectTimeout(5000);
    httpClientFeedFetcher.setReadTimeout(5000);
    return httpClientFeedFetcher.retrieveFeed(userAgent, new URL(url));
  } catch (IOException | FeedException | FetcherException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:12,代码来源:RssFeedItemImportService.java

示例2: test

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
@Test
public void test() throws Exception {
    FeedFetcherCache cache = HashMapFeedInfoCache.getInstance();
    FeedFetcher fetcher = new HttpURLFeedFetcher(cache);
    SyndFeed feed = fetcher.retrieveFeed(new URL("https://www.w3.org/blog/news/feed/atom"));

    assertEquals("W3C News", feed.getTitle());
}
 
开发者ID:rometools,项目名称:rome,代码行数:9,代码来源:FetcherIT.java

示例3: testFetchEventsWithCache

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
/**
 * Test events fired when there is a cache in use
 *
 */
public void testFetchEventsWithCache() {
    final FeedFetcherCache feedInfoCache = new HashMapFeedInfoCache();
    final FeedFetcher feedFetcher = getFeedFetcher(feedInfoCache);
    final FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
    feedFetcher.addFetcherEventListener(listener);
    try {
        SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
        assertNotNull(feed);
        assertTrue(listener.polled);
        assertTrue(listener.retrieved);
        assertFalse(listener.unchanged);
        listener.reset();

        // Since the feed is cached, the second request should not
        // actually retrieve the feed
        feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet/"));
        assertNotNull(feed);
        assertTrue(listener.polled);
        assertFalse(listener.retrieved);
        assertTrue(listener.unchanged);
        listener.reset();

        // now simulate getting the feed after it has changed
        feed = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort + "/rome/FetcherTestServlet?refreshfeed=TRUE"));
        assertNotNull(feed);
        assertTrue(listener.polled);
        assertTrue(listener.retrieved);
        assertFalse(listener.unchanged);
        listener.reset();
    } catch (final Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:39,代码来源:AbstractJettyTest.java

示例4: testDeltaEncoding

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
public void testDeltaEncoding() {
    final FeedFetcherCache feedInfoCache = new HashMapFeedInfoCache();
    final FeedFetcher feedFetcher = getFeedFetcher(feedInfoCache);
    try {
        feedFetcher.setUsingDeltaEncoding(true);

        // first retrieval should just grab the default feed
        final SyndFeed feed1 = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort
                + "/rome/FetcherTestServlet?deltaencode=TRUE&refreshfeed=TRUE"));
        assertNotNull(feed1);
        assertEquals("atom_1.0.feed.title", feed1.getTitle());
        assertEquals(2, feed1.getEntries().size());
        SyndEntry entry1 = feed1.getEntries().get(0);
        assertEquals("atom_1.0.feed.entry[0].title", entry1.getTitle());

        // second retrieval should get only the new item
        /*
         * This is breaking with Rome 0.5 ??
         */
        final SyndFeed feed2 = feedFetcher.retrieveFeed(new URL("http://localhost:" + testPort
                + "/rome/FetcherTestServlet?deltaencode=TRUE&refreshfeed=TRUE"));
        assertNotNull(feed2);
        assertEquals(FetcherTestServlet.DELTA_FEED_TITLE, feed2.getTitle());
        assertEquals(3, feed2.getEntries().size());
        entry1 = feed2.getEntries().get(0);
        assertEquals(FetcherTestServlet.DELTA_FEED_ENTRY_TITLE, entry1.getTitle());

        final SyndEntry entry2 = feed2.getEntries().get(1);
        assertEquals("atom_1.0.feed.entry[0].title", entry2.getTitle());

    } catch (final Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:36,代码来源:AbstractJettyTest.java

示例5: DeltaFeedInfoCache

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
public DeltaFeedInfoCache(final FeedFetcherCache backingCache) {
    this.backingCache = backingCache;
}
 
开发者ID:rometools,项目名称:rome,代码行数:4,代码来源:DeltaFeedInfoCache.java

示例6: Subscriptions

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
public Subscriptions(final FeedFetcherCache cache, final Requester requester, final String callbackPrefix, final SubDAO dao) {
    this.cache = cache;
    this.requester = requester;
    this.callbackPrefix = callbackPrefix;
    this.dao = dao;
}
 
开发者ID:rometools,项目名称:rome,代码行数:7,代码来源:Subscriptions.java

示例7: setCache

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
/**
 * @param cache the cache to set
 */
public void setCache(final FeedFetcherCache cache) {
    this.cache = cache;
}
 
开发者ID:rometools,项目名称:rome,代码行数:7,代码来源:Subscriptions.java

示例8: getFeedFetcher

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
@Override
protected FeedFetcher getFeedFetcher(final FeedFetcherCache cache) {
    return new HttpURLFeedFetcher(cache);
}
 
开发者ID:rometools,项目名称:rome,代码行数:5,代码来源:HttpURLFeedFetcherTest.java

示例9: getFeedFetcher

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
@Override
protected FeedFetcher getFeedFetcher(final FeedFetcherCache cache) {
    return new HttpClientFeedFetcher(cache);
}
 
开发者ID:rometools,项目名称:rome,代码行数:5,代码来源:HttpClientFeedFetcherTest.java

示例10: main

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
public static void main(final String[] args) {

        boolean ok = false;

        if (args.length >= 2) {

            try {

                final String outputType = args[0];

                final SyndFeed feed = new SyndFeedImpl();
                feed.setFeedType(outputType);

                feed.setTitle("Aggregated Feed");
                feed.setDescription("Anonymous Aggregated Feed");
                feed.setAuthor("anonymous");
                feed.setLink("http://www.anonymous.com");

                final List<SyndEntry> entries = new ArrayList<SyndEntry>();
                feed.setEntries(entries);

                final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
                final FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);

                for (int i = 1; i < args.length; i++) {
                    final URL inputUrl = new URL(args[i]);
                    final SyndFeed inFeed = feedFetcher.retrieveFeed(inputUrl);
                    entries.addAll(inFeed.getEntries());
                }

                final SyndFeedOutput output = new SyndFeedOutput();
                output.output(feed, new PrintWriter(System.out));

                ok = true;

            } catch (final Exception ex) {
                System.out.println("ERROR: " + ex.getMessage());
                ex.printStackTrace();
            }

        }

        if (!ok) {
            System.out.println();
            System.out.println("FeedAggregator aggregates different feeds into a single one.");
            System.out.println("The first parameter must be the feed type for the aggregated feed.");
            System.out.println(" [valid values are: rss_0.9, rss_0.91, rss_0.92, rss_0.93, ]");
            System.out.println(" [                  rss_0.94, rss_1.0, rss_2.0 & atom_0.3  ]");
            System.out.println("The second to last parameters are the URLs of feeds to aggregate.");
            System.out.println();
        }
    }
 
开发者ID:rometools,项目名称:rome,代码行数:53,代码来源:FeedAggregator.java

示例11: main

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
public static void main(final String[] args) {

        boolean ok = false;

        if (args.length == 1) {

            try {
                final URL feedUrl = new URL(args[0]);
                final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
                final FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);

                final FetcherEventListenerImpl listener = new FetcherEventListenerImpl();

                fetcher.addFetcherEventListener(listener);

                System.err.println("Retrieving feed " + feedUrl);
                // Retrieve the feed.
                // We will get a Feed Polled Event and then a
                // Feed Retrieved event (assuming the feed is valid)
                final SyndFeed feed = fetcher.retrieveFeed(feedUrl);

                System.err.println(feedUrl + " retrieved");
                System.err.println(feedUrl + " has a title: " + feed.getTitle() + " and contains " + feed.getEntries().size() + " entries.");
                // We will now retrieve the feed again. If the feed is unmodified
                // and the server supports conditional gets, we will get a "Feed
                // Unchanged" event after the Feed Polled event
                System.err.println("Polling " + feedUrl + " again to test conditional get support.");
                fetcher.retrieveFeed(feedUrl);
                System.err.println("If a \"Feed Unchanged\" event fired then the server supports conditional gets.");

                ok = true;

            } catch (final Exception ex) {
                System.out.println("ERROR: " + ex.getMessage());
                ex.printStackTrace();
            }

        }

        if (!ok) {
            System.out.println();
            System.out.println("FeedReader reads and prints any RSS/Atom feed type.");
            System.out.println("The first parameter must be the URL of the feed to read.");
            System.out.println();
        }

    }
 
开发者ID:rometools,项目名称:rome,代码行数:48,代码来源:FeedReader.java

示例12: RSSFetcherRunner

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
public RSSFetcherRunner(final String rssUrl, final Port out) throws MalformedURLException {
    this.feedUrl = new URL(rssUrl);
    final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
    this.fetcher = new HttpURLFeedFetcher(feedInfoCache);

    final FetcherListener listener = new RSSEventListener(out);

    this.fetcher.addFetcherEventListener(listener);


}
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:12,代码来源:RSSFetcherRunner.java

示例13: getFeedFetcher

import com.rometools.fetcher.impl.FeedFetcherCache; //导入依赖的package包/类
protected abstract FeedFetcher getFeedFetcher(FeedFetcherCache cache); 
开发者ID:rometools,项目名称:rome,代码行数:2,代码来源:AbstractJettyTest.java


注:本文中的com.rometools.fetcher.impl.FeedFetcherCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。