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
Nested ClassesModifier and TypeClassDescriptionprotected classThe feed cache loader, delegates the loading to the component's loadFeed method (to be easily overridable).protected classRunnable loading an URL into the cache. - 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LoadingCache<String,FeedResult> The user information cache.static final StringThe component role. - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected CloseableHttpClientBuild a HttpClient objectGet a feed.getFeedNoCache(String feedUrl) Get a feed not from the cache.voidprotected FeedResultRetrieve a feed's content to store it into the cache.voidpreload(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:
 initializein 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
 
 -