Dekoh platform API

dekoh.portal.syndication.aggregator.core
Class AggregatorImpl

java.lang.Object
  extended by dekoh.portal.syndication.aggregator.core.AggregatorImpl
All Implemented Interfaces:
Aggregator

public class AggregatorImpl
extends Object
implements Aggregator

AggregatorImpl is the default feed aggregator implementation provided. Instances of this can be created by AggregatorFactory . All instances of this class will share a single timer thread. Aggregator timer task will be non blocking and will return once it has submited the aggragation job to an executor pool.

Since:
Oct 25, 2007

Field Summary
protected  File cacheDir
           
protected  FeedRetriever feedRetriever
           
 
Method Summary
 void addAggregatedItemTransformer(AggregatedItemTransformer[] transformers)
           
 void destroy()
          Stops the scheduler.
 List getAggregatedItemTransformers()
           
 File getAggregatedRSSFeedXml()
          After aggregation the aggregated feed is stored in a file named "aggregate-subscriptionListId.xml", if it is an inMemorySubscriptionList, aggregated file will be stored as "aggregate-aggregatorId.xml"
 FeedRetriever getFeedRetriever()
           
 String getId()
           
 File getItemRSSFeedXml(String subscriptionItemId)
          Each downloaded subscription item feed is stored in a file named "aggregate-subscriptionListId-subscriptionItemId.xml"
 long getLastAggregatedTime()
           
 long getLastModifiedTime()
           
 int getMaxItemsToAggregate()
           
 long getSchedulerFrequency()
          
 SubscriptionItemFetcher getSubscriptionItemFetcher()
           
 SubscriptionList getSubscriptionList()
           
 boolean isScheduled()
           
 void scheduleAggregation()
          Triggers a periodic aggregation that becomes enabled now, and subsequently repeats itself after a frequency.Implementatin can chose to have a defualt frequency or take in the the constructor

Generally this will be a one time call, However it can be used to start aggregation "now", to check for latest feeds

 void scheduleAggregation(long frequencyInMilliSec)
          It will stop the aggregation if it is running and reschedule the aggregation with the specified frequecy
 void setMaxItemsToAggregate(int maxItemsToAggregate)
           
 void stopScheduler()
          Stops the scheduling of aggregator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

feedRetriever

protected FeedRetriever feedRetriever

cacheDir

protected File cacheDir
Method Detail

getSubscriptionItemFetcher

public SubscriptionItemFetcher getSubscriptionItemFetcher()

getFeedRetriever

public FeedRetriever getFeedRetriever()

getId

public final String getId()
Specified by:
getId in interface Aggregator
Returns:
An id which can be used to find this aggregator instance

getAggregatedItemTransformers

public List getAggregatedItemTransformers()
Specified by:
getAggregatedItemTransformers in interface Aggregator
Returns:
the transformer which will be given a callback before a new feed entry is made part of aggregated item

getMaxItemsToAggregate

public int getMaxItemsToAggregate()
Specified by:
getMaxItemsToAggregate in interface Aggregator
Returns:
maximum feed entries that will be part of aggregation

getSubscriptionList

public SubscriptionList getSubscriptionList()
Specified by:
getSubscriptionList in interface Aggregator
Returns:
SubscriptionList which is scheduked for aggregation

getLastAggregatedTime

public long getLastAggregatedTime()
Specified by:
getLastAggregatedTime in interface Aggregator
Returns:
time in milliseconds when the aggragation las happened

getLastModifiedTime

public long getLastModifiedTime()
Specified by:
getLastModifiedTime in interface Aggregator
Returns:
time in millisecond when the aggregated feed was las modified

setMaxItemsToAggregate

public void setMaxItemsToAggregate(int maxItemsToAggregate)
Specified by:
setMaxItemsToAggregate in interface Aggregator
Parameters:
maxItemsToAggregate - maximum items that will be aggregated byu this aggregater. Aggregators may choose a policy to remove items from the aggregated feed if the total no of aggregated items exceeds this limit.

getAggregatedRSSFeedXml

public File getAggregatedRSSFeedXml()
After aggregation the aggregated feed is stored in a file named "aggregate-subscriptionListId.xml", if it is an inMemorySubscriptionList, aggregated file will be stored as "aggregate-aggregatorId.xml"

Specified by:
getAggregatedRSSFeedXml in interface Aggregator
Returns:
the file representing aggregated feed

scheduleAggregation

public void scheduleAggregation()
Description copied from interface: Aggregator
Triggers a periodic aggregation that becomes enabled now, and subsequently repeats itself after a frequency.Implementatin can chose to have a defualt frequency or take in the the constructor

Generally this will be a one time call, However it can be used to start aggregation "now", to check for latest feeds

Specified by:
scheduleAggregation in interface Aggregator
See Also:
Aggregator.scheduleAggregation(long)

scheduleAggregation

public void scheduleAggregation(long frequencyInMilliSec)
It will stop the aggregation if it is running and reschedule the aggregation with the specified frequecy

Specified by:
scheduleAggregation in interface Aggregator
Parameters:
frequencyInMilliSec - frequency with which aggregation will happen

stopScheduler

public void stopScheduler()
Description copied from interface: Aggregator
Stops the scheduling of aggregator. The subscription items in the list will not be downloaded and aggregated any more

Specified by:
stopScheduler in interface Aggregator
See Also:
Aggregator.scheduleAggregation(long)

isScheduled

public boolean isScheduled()
Specified by:
isScheduled in interface Aggregator
Returns:
true if the aggregator is scheduled
false if aggregator was never scheduled or is stopped

getSchedulerFrequency

public long getSchedulerFrequency()

Specified by:
getSchedulerFrequency in interface Aggregator
Returns:
frequency in milliseconds at which the aggregator is scheduled, value of zero indicate that the aggregator was never scheduled or is stopeed.

destroy

public void destroy()
Stops the scheduler. If it is aggregating an InMemorySubscriptionList deletes all the downloaded feeds files and the aggregated file created during the aggregation process

Specified by:
destroy in interface Aggregator

addAggregatedItemTransformer

public void addAggregatedItemTransformer(AggregatedItemTransformer[] transformers)
Specified by:
addAggregatedItemTransformer in interface Aggregator
Parameters:
transformers - which will be given a callback before a new feed entry is made part of aggregated item

getItemRSSFeedXml

public File getItemRSSFeedXml(String subscriptionItemId)
Each downloaded subscription item feed is stored in a file named "aggregate-subscriptionListId-subscriptionItemId.xml"

Specified by:
getItemRSSFeedXml in interface Aggregator
Parameters:
subscriptionItemId - id of a subscription item in the list
Returns:
the downloaded feed for the subscription item

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers