Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The existing INewsAdapter requires access to the PortletRequest while retrieving news feeds.  A prefetching implementation would need to be able to request feeds without access to a specific PortletRequest object.

AntiSamy Configuration

...

AntiSamy policy files are currently configured on a portlet-by-portlet basis using the portlet preferences API.  While this makes it easy to define both default and portlet-specific values, it places some of the configuration in the PortletPreferences object, which can only be accessed via a PortletRequest.  This strategy also makes it difficult to configure feed-specific policies.

We should instead define a default in configuration.properties, overriding this on a feed-specific basis

...

by using a NewsDefinition parameter.

New IPrefetchableNewsAdapter API

INewsAdapter

The current news adapter API defines a single feed retrieval method that takes a NewConfiguration and a PortletRequest object as parameters.  Both these objects are user-specific and it would not be prudent to request a feed using these user-specific objects in the absence of an actual user request.

 

Code Block
languagejava
public interface INewsAdapter {
    public NewsFeed getSyndFeed(NewsConfiguration config, PortletRequest request);
}

To enable feed prefetching, we can create a an extension of the interface that allows prefetching.  This interface would add an additional method that retrieves a feed simply from the NewsDefinition object.  These feeds should be explicitly marked in the parameters as prefetched or not, and we might also want to configure parameters such as the fetch frequency.

Code Block
languagejava
public interface IPrefetchableNewsAdapter

...

 extends INewsAdapter {
    public NewsFeed getSyndFeed(NewsDefinition def)

...

;
}

 

prefetchable NewsDefinition Parameters

  • prefetching enabled/disabled
  • fetch frequency

Caching and Prefetching Implementation

Feeds may be regularly prefetched using either the Spring Timer API (in the JSR-286 version) or Quartz.  Feed prefetching might work by:

  1. Query database for registered feeds with prefetching enabled
  2. Use Quartz/Spring Timer to regularly fetch feeds.  Upon successful fetch, update cache.
  3. Caching via ehcache configured such that feed should only be fetched by timer job.  Optionally persist to disk.