Expresso 5-6

com.jcorporate.expresso.services.crontab
Class Crontab

java.lang.Object
  extended bycom.jcorporate.expresso.services.crontab.Crontab

public class Crontab
extends Object

This is the main API controller class that deals with the various crontab entries.

Author:
Mike Dubman

Field Summary
protected  SortedSet queue
          The queue waiting for execution.
protected  CronDaemon waiter
          The thread that manages the crontab entries.
 
Constructor Summary
Crontab()
          Default constructor
Crontab(boolean isDaemon, String threadName)
          Construct the Crontab thread
 
Method Summary
 void addCrontabEntry(CrontabEntry entry)
          Add a constructed Crontab entry to the Crontab.
 CrontabEntry addCrontabEntry(Date date, CrontabListenerI listener)
          Add a crontab entry
 CrontabEntry addCrontabEntry(int delay, boolean isRepetitive, CrontabListenerI listener)
          Add a crontab entry
 CrontabEntry addCrontabEntry(int minute, int hour, int dayOfMonth, int month, int dayOfWeek, int year, CrontabListenerI listener)
          Adds a crontab to execute based upon various Cron-like parameters as numbers
 CrontabEntry addCrontabEntry(int minute, int hour, int dayOfMonth, int month, int dayOfWeek, int year, String label, CrontabListenerI listener)
          Adds a crontab to execute based upon various Cron-like parameters as numbers
 CrontabEntry addCrontabEntry(int minute, int hour, int dayOfMonth, int month, int dayOfWeek, int year, String label, CrontabListenerI listener, String jobNumber)
          Adds a crontab to execute based upon various Cron-like parameters as numbers
 boolean containsCrontabEntry(CrontabEntry oneEntry)
          Checks if a given crontab entry is sitting in the queue waiting for execution
 void finalize()
          Clearing the cron thread if the crontab is killed
 List getAllEntries()
          Retrieve a list of all items that are part of the queue.
protected  void notifyListeners()
          When this is called, we execute the given crontab
 void removeAllCrontabEntries()
          Remove all existing crontabs from the crontab entry.
 boolean removeCrontabEntry(CrontabEntry entry)
          Remove a given crontab entry from the crontab
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

waiter

protected CronDaemon waiter
The thread that manages the crontab entries. It does so by simply ringing this particular class that a cron is ready to run.


queue

protected SortedSet queue
The queue waiting for execution. Sorting in the set is determined by the next execution time.

Constructor Detail

Crontab

public Crontab(boolean isDaemon,
               String threadName)
Construct the Crontab thread

Parameters:
isDaemon - set to true if the crontab should be a daemon thread
threadName - the name of the thread

Crontab

public Crontab()
Default constructor

Method Detail

addCrontabEntry

public CrontabEntry addCrontabEntry(Date date,
                                    CrontabListenerI listener)
                             throws CronException
Add a crontab entry

Parameters:
date - the date for the crontab entry to execute
listener - the listener interface
Returns:
CrontabEntry representing what was just constructed
Throws:
CronException - upon error constructing the CrontabEntry

addCrontabEntry

public CrontabEntry addCrontabEntry(int delay,
                                    boolean isRepetitive,
                                    CrontabListenerI listener)
                             throws CronException
Add a crontab entry

Parameters:
delay - the delay in(?) before executing the crontab
isRepetitive - true if the crontab is repetitive, ie should it execute every X many seconds
listener - the listener to get notified when a crontab executes
Returns:
CrontabEntry
Throws:
CronException - upon error creating the crontab entry

addCrontabEntry

public CrontabEntry addCrontabEntry(int minute,
                                    int hour,
                                    int dayOfMonth,
                                    int month,
                                    int dayOfWeek,
                                    int year,
                                    CrontabListenerI listener)
                             throws CronException
Adds a crontab to execute based upon various Cron-like parameters as numbers

Parameters:
minute - execute every X minutes
hour - execute every X hours
dayOfMonth - execute every X days of the month
month - execute every X days of the month
dayOfWeek - execute every specified day of the week
year - execute every X specified years
listener - the listener to get notified when the crontab's time is due
Returns:
Crontab Entry
Throws:
CronException - upon construction error

addCrontabEntry

public CrontabEntry addCrontabEntry(int minute,
                                    int hour,
                                    int dayOfMonth,
                                    int month,
                                    int dayOfWeek,
                                    int year,
                                    String label,
                                    CrontabListenerI listener)
                             throws CronException
Adds a crontab to execute based upon various Cron-like parameters as numbers

Parameters:
minute - execute every X minutes
hour - execute every X hours
dayOfMonth - execute every X days of the month
month - execute every X days of the month
dayOfWeek - execute every specified day of the week
year - execute every X specified years
label - Useful label for possible debugging purposes
listener - the listener to get notified when the crontab's time is due
Returns:
Crontab Entry
Throws:
CronException - upon construction error

addCrontabEntry

public CrontabEntry addCrontabEntry(int minute,
                                    int hour,
                                    int dayOfMonth,
                                    int month,
                                    int dayOfWeek,
                                    int year,
                                    String label,
                                    CrontabListenerI listener,
                                    String jobNumber)
                             throws CronException
Adds a crontab to execute based upon various Cron-like parameters as numbers

Parameters:
minute - execute every X minutes
hour - execute every X hours
dayOfMonth - execute every X days of the month
month - execute every X days of the month
dayOfWeek - execute every specified day of the week
year - execute every X specified years
label - Useful label for possible debugging purposes
listener - the listener to get notified when the crontab's time is due
jobNumber - Job Number for this CrontabEntry's associated JobQueue entry
Returns:
Crontab Entry
Throws:
CronException - upon construction error

addCrontabEntry

public void addCrontabEntry(CrontabEntry entry)
                     throws CronException
Add a constructed Crontab entry to the Crontab.

Parameters:
entry - the entry to add
Throws:
CronException

removeCrontabEntry

public boolean removeCrontabEntry(CrontabEntry entry)
Remove a given crontab entry from the crontab

Parameters:
entry - the entry to remove
Returns:
boolean

removeAllCrontabEntries

public void removeAllCrontabEntries()
Remove all existing crontabs from the crontab entry.


containsCrontabEntry

public boolean containsCrontabEntry(CrontabEntry oneEntry)
Checks if a given crontab entry is sitting in the queue waiting for execution

Parameters:
oneEntry - a given entry.
Returns:
true if the given entry exists in the queue

getAllEntries

public List getAllEntries()
Retrieve a list of all items that are part of the queue.

Returns:
a List of CrontabEntry objects

notifyListeners

protected void notifyListeners()
When this is called, we execute the given crontab


finalize

public void finalize()
Clearing the cron thread if the crontab is killed


Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.