net.jot.scheduler
Class JOTScheduler

java.lang.Object
  extended by java.lang.Thread
      extended by net.jot.scheduler.JOTScheduler
All Implemented Interfaces:
java.lang.Runnable

public class JOTScheduler
extends java.lang.Thread

Generic scheduler, that can run scheduled task/items. any task can be registered into the scheduler using registerItem() Works like a cron mostly. It is started by JOT at startup (by JOTInitializer) Note that new jobs are looked for every minute, so the "granularity" is about 1 minute.

Author:
thibautc

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
static JOTScheduler getInstance()
           
 void registerItem(JOTScheduledItem item, JOTSchedulingOptions options)
          Register an item(ie: a job) in the scheduler.
 void run()
          Main scheduler loop.
 void shutdown()
          Shuts down the scheduler and release resources
 void unregisterItem(JOTScheduledItem item)
          Unregisters a job from the sheculer, ie: remove it.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static JOTScheduler getInstance()

shutdown

public void shutdown()
              throws java.lang.Exception
Shuts down the scheduler and release resources

Throws:
java.lang.Exception

registerItem

public void registerItem(JOTScheduledItem item,
                         JOTSchedulingOptions options)
Register an item(ie: a job) in the scheduler.

Parameters:
item -
options -

unregisterItem

public void unregisterItem(JOTScheduledItem item)
Unregisters a job from the sheculer, ie: remove it.

Parameters:
item -

run

public void run()
Main scheduler loop. Once scheduler.start() is call, it should run forever.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread