net.spy.cron
Class Job

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.cron.Job
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
MainJob, URLItem

public abstract class Job
extends SpyObject
implements java.lang.Runnable

All Jobs should implement this interface.


Constructor Summary
Job(java.lang.String name, java.util.Date startDate)
          Get a new Job with the given name and start date.
Job(java.lang.String name, java.util.Date startDate, TimeIncrement ti)
          Get a new recurring Job with the given name and start date that will run on an interval defined by the TimeIncrement.
 
Method Summary
 void findNextRun()
          Find the next time this Job should be run and adjust the start date accordingly.
 java.lang.String getName()
          Get the name of this thing.
 java.util.Date getStartTime()
          Get the time this job was requested to start.
protected  TimeIncrement getTimeIncrement()
          Get the current TimeIncrement object incrementing the time on this job.
 boolean isAlive()
          Is this job alive (is it running)?
 boolean isReady()
          Is this Job ready to go?
 boolean isTrash()
          Is this Job ready to be thrown away?
protected  void markFinished()
          Mark this job as having stopped running.
protected  void markStarted()
          Mark this job as having been started.
 void run()
          Mark started, call runJob, then mark finished.
protected abstract  void runJob()
          Subclasses of Job should extend this method to implement their running.
 void setName(java.lang.String to)
          Set the name of this thing.
 void setStartTime(java.util.Date to)
          Set the next time the job is due to start.
protected  void stopRunning()
          Stop this job from running.
 java.lang.String toString()
          Get a string representation of this Job.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Job

public Job(java.lang.String name,
           java.util.Date startDate)
Get a new Job with the given name and start date.


Job

public Job(java.lang.String name,
           java.util.Date startDate,
           TimeIncrement ti)
Get a new recurring Job with the given name and start date that will run on an interval defined by the TimeIncrement.

Method Detail

toString

public java.lang.String toString()
Get a string representation of this Job.

Overrides:
toString in class java.lang.Object

setName

public void setName(java.lang.String to)
Set the name of this thing.


getName

public java.lang.String getName()
Get the name of this thing.


getStartTime

public java.util.Date getStartTime()
Get the time this job was requested to start.


setStartTime

public void setStartTime(java.util.Date to)
Set the next time the job is due to start.


isReady

public boolean isReady()
Is this Job ready to go?


run

public final void run()
Mark started, call runJob, then mark finished.

Specified by:
run in interface java.lang.Runnable

runJob

protected abstract void runJob()
Subclasses of Job should extend this method to implement their running.


isTrash

public boolean isTrash()
Is this Job ready to be thrown away?


getTimeIncrement

protected TimeIncrement getTimeIncrement()
Get the current TimeIncrement object incrementing the time on this job.

Returns:
the TimeIncrement

markStarted

protected void markStarted()
Mark this job as having been started.


findNextRun

public final void findNextRun()
Find the next time this Job should be run and adjust the start date accordingly. This method will be called by JobQueue when looking for tasks to run.


stopRunning

protected void stopRunning()
Stop this job from running.


isAlive

public boolean isAlive()
Is this job alive (is it running)?


markFinished

protected void markFinished()
Mark this job as having stopped running.



Copyright © 1995-2005 SPY Internetworking. All Rights Reserved.