Package org.ametys.plugins.syndication
Class FeedCache
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.syndication.FeedCache
- All Implemented Interfaces:
Initializable
,Component
,LogEnabled
Feed cache, supports preloading multiple feeds in multiple concurrent threads.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
The feed cache loader, delegates the loading to the component's loadFeed method (to be easily overridable).protected class
Runnable loading an URL into the cache. -
Field Summary
Modifier and TypeFieldDescriptionprotected LoadingCache<String,
FeedResult> The user information cache.static final String
The component role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CloseableHttpClient
Build a HttpClient objectGet a feed.getFeedNoCache
(String feedUrl) Get a feed not from the cache.void
protected FeedResult
Retrieve a feed's content to store it into the cache.void
preload
(Collection<String> feeds) Pre-load a collection of feeds, one by thread, to avoid getting timeouts sequentially.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
The component role. -
_cache
The user information cache.
-
-
Constructor Details
-
FeedCache
public FeedCache()
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
preload
Pre-load a collection of feeds, one by thread, to avoid getting timeouts sequentially.- Parameters:
feeds
- the feeds to preload.
-
getFeedNoCache
Get a feed not from the cache.- Parameters:
feedUrl
- the feed.- Returns:
- the feed result.
- Throws:
IOException
- if an error occurs while loading the feed
-
getFeed
Get a feed.- Parameters:
feedUrl
- the feed.lifeTime
- the amount of date or time to be added to the field- Returns:
- the feed response.
-
_getHttpClient
Build a HttpClient object- Returns:
- The HttpClient object
-
loadFeed
Retrieve a feed's content to store it into the cache.- Parameters:
feedUrl
- the feed to load.- Returns:
- the feed content.
- Throws:
IOException
- if an error occurs with theHttpURLConnection
-