org.mmbase.applications.crontab
Class CronDaemon

java.lang.Object
  extended byjava.util.TimerTask
      extended byorg.mmbase.applications.crontab.CronDaemon
All Implemented Interfaces:
Runnable

public class CronDaemon
extends TimerTask

CronDaemon is a "crontab" clone written in java. The daemon starts a thread that wakes up every minute (it keeps sync by calculating the time to sleep)

Author:
Kees Jongenburger, Michiel Meeuwissen

Method Summary
 void add(CronEntry entry)
          Adds the given CronEntry to this daemon.
protected  void addEntry(CronEntry entry)
          Actually adds, no checks for 'removedEntries' and so on.
protected static CronEntry getById(Set set, String id)
          Finds in given set the CronEntry with the given id.
 CronEntry getCronEntry(String id)
           
 Set getEntries()
           
static CronDaemon getInstance()
          Singleton, Gets (and instantiates, and starts) the one CronDaemon instance.
 boolean isAlive()
           
static void main(String[] argv)
          main only for testing purposes
 void remove(CronEntry entry)
          Remove the given CronEntry from this daemon.
protected  void removeEntry(CronEntry entry)
          Actually removes, nor checks for removedEntries' and so on.
 void run()
          The main loop of the daemon, which of course is a Thread, implemented in run() to satisfy the 'Runnable' interface.
 void start()
          Starts the daemon, which you might want to do if you have stopped if for some reason.
 void stop()
          If you like to temporary stop the daemon, call this.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getById

protected static CronEntry getById(Set set,
                                   String id)
Finds in given set the CronEntry with the given id.

Returns:
a CronEntry if found, null otherwise.

add

public void add(CronEntry entry)
Adds the given CronEntry to this daemon.

Throws:
RuntimeException - If an entry with the same id is present already (unless it is running and scheduled for removal already)

addEntry

protected void addEntry(CronEntry entry)
Actually adds, no checks for 'removedEntries' and so on.


getCronEntry

public CronEntry getCronEntry(String id)

remove

public void remove(CronEntry entry)
Remove the given CronEntry from this daemon. If the entry is currently running, it will be postponed until this job is ready.


removeEntry

protected void removeEntry(CronEntry entry)
Actually removes, nor checks for removedEntries' and so on.


start

public void start()
Starts the daemon, which you might want to do if you have stopped if for some reason. The daemon is already started on default.


stop

public void stop()
If you like to temporary stop the daemon, call this.


isAlive

public boolean isAlive()

getInstance

public static CronDaemon getInstance()
Singleton, Gets (and instantiates, and starts) the one CronDaemon instance.


run

public void run()
The main loop of the daemon, which of course is a Thread, implemented in run() to satisfy the 'Runnable' interface.


getEntries

public Set getEntries()
Since:
MMBase-1.8

main

public static void main(String[] argv)
                 throws Exception
main only for testing purposes

Throws:
Exception


MMBase build 1.8.1.20060716