|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectto.etc.domui.util.janitor.Janitor
public class Janitor
The Janitor class handles all housekeeping chores for NEMA and NEMA-derived applications. The janitor is started as a separate thread (by the ResourceBroker). It maintains a list of things-to-do, where each thing will be scheduled at a specified interval. Each janitor task will be scheduled in a separate thread. The max. number of threads (janitor jobs) can be specified. As soon a job finishes it is rescheduled (if required) at the interval specified. Since rescheduling will only take place after the task has finished there's no risk for running the same task twice. Internals: The janitor has a #of job slots. Each slot can contain a single thread. All Janitor threads derive from JanitorThread, a local class. The janitor's task list contains task entries, containing an interval and a reference to some class and method. The scheduler keeps all things to-do ordered by time-of-next-execution.
Constructor Summary | |
---|---|
Janitor(int maxjobs)
|
Method Summary | |
---|---|
int |
addTask(int interval,
boolean once,
java.lang.String name,
JanitorTask jt)
Add a new task to the janitor's tables. |
int |
addTaskAt(java.util.Date attime,
java.lang.String name,
JanitorTask jt)
Adds a task to the janitor's table. |
boolean |
cancelJob(int id)
|
static Janitor |
getJanitor()
Returns the Janitor, the class handling housekeeping chores. |
long |
getTime()
Returns the current time, in milliseconds, as returned from System.currentTimeMillis() |
long |
getTimeStamp()
Returns the last scheduler's run timestamp. |
protected void |
logTask(JanitorThread jt,
java.lang.String msg)
|
boolean |
mustTerminate()
|
void |
run()
The main Janitor thread loop. |
void |
start()
Starts this janitor as a new thread; it waits till the thread starts! |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Janitor(int maxjobs)
Method Detail |
---|
public void start()
public long getTime()
protected void logTask(JanitorThread jt, java.lang.String msg)
public int addTask(int interval, boolean once, java.lang.String name, JanitorTask jt) throws java.lang.Exception
interval
- interval in secondsonce
- TRUE if this is a single-shot eventname
- The name of the dude for info ppsjt
- The task functor to call at time zero.
java.lang.Exception
public int addTaskAt(java.util.Date attime, java.lang.String name, JanitorTask jt) throws java.lang.Exception
java.lang.Exception
public boolean cancelJob(int id)
public boolean mustTerminate()
public void run()
run
in interface java.lang.Runnable
public long getTimeStamp()
public static Janitor getJanitor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |