net.sourceforge.java.feednread.backend.jobs
Class NewsFeedAggregationManagerJob

java.lang.Object
  extended bynet.sourceforge.java.util.jobs.Job
      extended bynet.sourceforge.java.feednread.backend.jobs.NewsFeedAggregationManagerJob
All Implemented Interfaces:
IJob, IRunnableWithProgress

public class NewsFeedAggregationManagerJob
extends Job

Job to control and coordinate the aggregation of a bunch of Favorites i.e. their associated NewsFeeds.

Author:
Sebastian Machhausen

Field Summary
private  int activeAggregators
           The active aggregator count
private  List aggregatorJobs
           The list of Jobs used for aggregation
private  boolean isError
           Error flag: This is set to false if minimum one NewsFeedAggregatorJob succeeds.
private  MainApplicationWindow mainWindow
           The Feed'n Read main window
private  IProgressMonitor monitor
           The IProgressMonitor of the aggregation manager Job
private  AggregatedNewsFeed newsFeed
           The AggregatedNewsFeed to aggregate into
private  Favorite[] newsFeedFavorites
          * The Favorites to aggregate
 
Fields inherited from class net.sourceforge.java.util.jobs.Job
 
Fields inherited from interface net.sourceforge.java.util.jobs.IJob
HIGH_PRIORITY, LOW_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NewsFeedAggregationManagerJob(MainApplicationWindow mainWindow, Favorite[] newsFeedFavorites)
           Creates a new NewsFeedAggregationManagerJob which aggregates the specified Favorite newsfeeds into one single AggregatedNewsFeed and adds it to the NewsFeedTabBar when finished.
 
Method Summary
private  void aggregationFailed()
           Called in case this NewsFeedAggregationManagerJob failed.
private  void aggregationSucceeded()
           Called in case this NewsFeedAggregationManagerJob succeeded and aggregated at least one NewsFeed.
 void cancel()
           Cancels this NewsFeedAggregationManagerJob and all sub NewsFeedAggregatorJobs.
 void completed(NewsFeedAggregatorJob aggregator, NewsFeed parsedNewsFeed)
           Called from a NewsFeedAggregatorJob if it has completed.
private  void initializedAggregatedNewsFeed()
           Initializes the target AggregatedNewsFeed which holds all aggregated news entries.
 void run(IProgressMonitor monitor)
           Activates the aggregation process.
private  void showResult()
           Shows the result of the NewsFeedAggregationManagerJob.
 void spawnNewAggregator(Favorite newsFeedFavorite)
           Spawns a new NewsFeedAggregatorJob to parse/aggregate the specified newsfeed Favorite.
 
Methods inherited from class net.sourceforge.java.util.jobs.Job
done, getException, getJobManager, getName, getPriority, getStatus, getThread, isCanceled, join, setException, setJobManager, setName, setPriority, setThread, start, started, statusChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainWindow

private MainApplicationWindow mainWindow

The Feed'n Read main window


monitor

private IProgressMonitor monitor

The IProgressMonitor of the aggregation manager Job


aggregatorJobs

private List aggregatorJobs

The list of Jobs used for aggregation


newsFeedFavorites

private Favorite[] newsFeedFavorites

* The Favorites to aggregate


activeAggregators

private int activeAggregators

The active aggregator count


newsFeed

private AggregatedNewsFeed newsFeed

The AggregatedNewsFeed to aggregate into


isError

private boolean isError

Error flag: This is set to false if minimum one NewsFeedAggregatorJob succeeds. The flag is initially set to true.

Constructor Detail

NewsFeedAggregationManagerJob

public NewsFeedAggregationManagerJob(MainApplicationWindow mainWindow,
                                     Favorite[] newsFeedFavorites)

Creates a new NewsFeedAggregationManagerJob which aggregates the specified Favorite newsfeeds into one single AggregatedNewsFeed and adds it to the NewsFeedTabBar when finished.

Parameters:
mainWindow - the Feed'n Read main window
newsFeedFavorites - the Favorite newsfeeds to aggregate
Method Detail

cancel

public void cancel()

Cancels this NewsFeedAggregationManagerJob and all sub NewsFeedAggregatorJobs.

Specified by:
cancel in interface IJob
Overrides:
cancel in class Job

run

public void run(IProgressMonitor monitor)

Activates the aggregation process.

Parameters:
monitor - the IProgressMonitor to use for reporting the progress of this NewsFeedAggregationManagerJob
See Also:
IRunnableWithProgress.run(org.eclipse.core.runtime.IProgressMonitor), IJob.getException()

showResult

private void showResult()

Shows the result of the NewsFeedAggregationManagerJob. This is the last chance to trigger a cancellation.


aggregationSucceeded

private void aggregationSucceeded()

Called in case this NewsFeedAggregationManagerJob succeeded and aggregated at least one NewsFeed. A new tab is added to the NewsFeedTabBar showing all aggregated NewsFeeds. In addition a success message is shown in the application status line.


aggregationFailed

private void aggregationFailed()

Called in case this NewsFeedAggregationManagerJob failed. This only happens if all NewsFeedAggregatorJobs failed. An error message is shown in the application status line.


spawnNewAggregator

public void spawnNewAggregator(Favorite newsFeedFavorite)

Spawns a new NewsFeedAggregatorJob to parse/aggregate the specified newsfeed Favorite.

Parameters:
newsFeedFavorite - the Favorite newsfeed to parse/aggregate

completed

public void completed(NewsFeedAggregatorJob aggregator,
                      NewsFeed parsedNewsFeed)

Called from a NewsFeedAggregatorJob if it has completed. It may have succeded or failed. The NewsFeedAggregatorJob is removed from this NewsFeedAggregationManagerJob and the progress status of the aggregation process is reported.

Parameters:
aggregator - the NewsFeedAggregatorJob that completed
parsedNewsFeed - the NewsFeed parsed by the specified NewsFeedAggregatorJob; null if the NewsFeedAggregatorJob failed

initializedAggregatedNewsFeed

private void initializedAggregatedNewsFeed()

Initializes the target AggregatedNewsFeed which holds all aggregated news entries.