net.sourceforge.java.util.jobs
Class Job

java.lang.Object
  extended bynet.sourceforge.java.util.jobs.Job
All Implemented Interfaces:
IJob, IRunnableWithProgress
Direct Known Subclasses:
DownloadJob, IdleJobStatusReaper, NewsFeedAggregationManagerJob, NewsFeedAggregatorJob, NewsFeedArchivingJob, NewsFeedFavoritesTreeOPMLImportJob, NewsFeedParserJob, NewsFeedUpdateManagerJob, TreeImportJob

public abstract class Job
extends Object
implements IJob

Default IJob implementation to be used as base for concrete Jobs.

Author:
Sebastian Machhausen

Field Summary
private  boolean canceled
           trueif the Job has been canceled; otherwise false
private  Exception exc
           The Exception that may potentially occur
private  String jobName
           The name of the Job
private  JobManager manager
           The JobManager that is responsible for this Job
private  int priority
           The Job priority.
private  JobStatus status
           The status of the Job
private  Thread thread
           The Thread that this Job runs in
 
Fields inherited from interface net.sourceforge.java.util.jobs.IJob
HIGH_PRIORITY, LOW_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Job()
           
 
Method Summary
 void cancel()
           Cancels this Job.
 void done()
           This method has to be called instantly after this Job is done.
 Exception getException()
           Gets the Exception that may have potentially occured causing the Job to fail.
 JobManager getJobManager()
           Gets the JobManager that is responsible for the management and scheduling of this Job.
 String getName()
           Gets the human readable name of this Job.
 int getPriority()
           Gets the priority of this Job.
 JobStatus getStatus()
           Gets the status of this Job.
 Thread getThread()
           Gets the Thread that this Job runs in.
 boolean isCanceled()
           Gets the cancellation status of this Job.
 void join()
           Joins this Job running in the set Thread as returned by the getThread() method.
 void setException(Exception cause)
           Sets the Exception that may have potentially occured causing the Job to fail.
 void setJobManager(JobManager manager)
           Sets the JobManager that is responsible for the management and scheduling of this Job.
 void setName(String name)
           Sets a human readable name for this Job.
 void setPriority(int priority)
           Sets the priority of this Job.
 void setThread(Thread thread)
           Sets the Thread that this Job runs in.
 void start()
           Starts this Job in the set Thread as returned by the getThread() method.
 void started()
           This method has to be called instantly after this Job has been started.
 void statusChanged()
           This method can be called if the JobStatus of this Job changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.operation.IRunnableWithProgress
run
 

Field Detail

priority

private int priority

The Job priority. By default a Job has norm priority.


manager

private JobManager manager

The JobManager that is responsible for this Job


thread

private Thread thread

The Thread that this Job runs in


exc

private Exception exc

The Exception that may potentially occur


jobName

private String jobName

The name of the Job


status

private JobStatus status

The status of the Job


canceled

private boolean canceled

trueif the Job has been canceled; otherwise false

Constructor Detail

Job

public Job()
Method Detail

setPriority

public void setPriority(int priority)

Sets the priority of this Job.

Predefined priorities are: The priority must therefore range between IJob.LOW_PRIORITY and IJob.HIGH_PRIORITY. Priorites beyons this interval will be rejected and don't change the current priority.

Specified by:
setPriority in interface IJob
Parameters:
priority - the priority to set for this Job
See Also:
getPriority()

getPriority

public int getPriority()

Gets the priority of this Job.

Predefined priorities are: The priority therefore ranges between IJob.LOW_PRIORITY and IJob.HIGH_PRIORITY.

Specified by:
getPriority in interface IJob
Returns:
the priority of this Job
See Also:
setPriority(int)

setJobManager

public void setJobManager(JobManager manager)

Sets the JobManager that is responsible for the management and scheduling of this Job.

Specified by:
setJobManager in interface IJob
Parameters:
manager - the JobManager that is responsible for the management and scheduling of this Job
See Also:
getJobManager()

getJobManager

public JobManager getJobManager()

Gets the JobManager that is responsible for the management and scheduling of this Job.

Specified by:
getJobManager in interface IJob
Returns:
the JobManager that is responsible for the management and scheduling of this Job
See Also:
setJobManager(JobManager)

setThread

public void setThread(Thread thread)

Sets the Thread that this Job runs in.

Specified by:
setThread in interface IJob
Parameters:
thread - the Thread that this Job runs in
See Also:
getThread()

getThread

public Thread getThread()

Gets the Thread that this Job runs in.

Specified by:
getThread in interface IJob
Returns:
the Thread that this Job runs in
See Also:
setThread(Thread)

setException

public void setException(Exception cause)

Sets the Exception that may have potentially occured causing the Job to fail.

Specified by:
setException in interface IJob
Parameters:
cause - the potential Exception; null if no Exception was thrown
See Also:
getException()

getException

public Exception getException()

Gets the Exception that may have potentially occured causing the Job to fail. This methode returns null if the Job succeeded.

Specified by:
getException in interface IJob
Returns:
the potential Exception; null if no Exception was thrown
See Also:
setException(Exception)

setName

public void setName(String name)

Sets a human readable name for this Job.

Specified by:
setName in interface IJob
Parameters:
name - a human readable name for this Job
See Also:
getName()

getName

public String getName()

Gets the human readable name of this Job.

Specified by:
getName in interface IJob
Returns:
the human readable name of this Job
See Also:
setName(String)

getStatus

public JobStatus getStatus()

Gets the status of this Job.

Specified by:
getStatus in interface IJob
Returns:
a JobStatus object representing the status of this Job

start

public void start()

Starts this Job in the set Thread as returned by the getThread() method. If no Thread is set this method does nothing.

Specified by:
start in interface IJob

started

public void started()

This method has to be called instantly after this Job has been started. Subclasses may override this method but need to call super.started() when finished to notify the responsible JobManager that this Job has been started.

Specified by:
started in interface IJob

join

public void join()
          throws InterruptedException

Joins this Job running in the set Thread as returned by the getThread() method. If no Thread is set this method does nothing.

Specified by:
join in interface IJob
Throws:
InterruptedException - if another Job has interrupted the current Job. The interrupted status of the current Job is cleared when this exception is thrown

done

public void done()

This method has to be called instantly after this Job is done. Subclasses may override this method but need to call super.done() when finished to notify the responsible JobManager that this Job is done.

Specified by:
done in interface IJob

statusChanged

public void statusChanged()

This method can be called if the JobStatus of this Job changed. Subclasses may override this method but need to call super.statusChanged() when finished to notify the responsible JobManager that the status of this Job changed.

Specified by:
statusChanged in interface IJob

cancel

public void cancel()

Cancels this Job.

Specified by:
cancel in interface IJob

isCanceled

public boolean isCanceled()

Gets the cancellation status of this Job.

Specified by:
isCanceled in interface IJob
Returns:
true if this Job has been canceled; false otherwise