Last update: 2011-06-23

org.proteios.core
Class JobQueueScheduler

java.lang.Object
  extended by java.util.TimerTask
      extended by org.proteios.core.JobQueueScheduler
All Implemented Interfaces:
Runnable

public final class JobQueueScheduler
extends TimerTask

This class schedules instances of job queue classes.

Version:
2.0
Author:
olle
Last modified
$Date: 2011-05-13 15:51:15 +0200 (Fri, 13 May 2011) $

Constructor Summary
protected JobQueueScheduler()
          JobQueueScheduler default constructor.
protected JobQueueScheduler(JobQueueManager jobQueueManagerToUse)
          JobQueueScheduler constructor.
 
Method Summary
static JobQueueManager getJobQueueManager()
          Get the job queue manager.
static boolean isRunning()
          Check if the job queue scheduler is running.
 void run()
          Check the database for jobs that are waiting to be executed.
protected  void runNextJobInQueue(ManageableJobQueueReadOnlyInterface jobQueue)
           
static void setJobQueueManager(JobQueueManager jobQueueManagerToUse)
          Set the job queue manager.
protected  void start()
          Starts the job queue scheduler.
protected  void stop()
          Stops the job queue scheduler.
 
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
 

Constructor Detail

JobQueueScheduler

protected JobQueueScheduler()
JobQueueScheduler default constructor.


JobQueueScheduler

protected JobQueueScheduler(JobQueueManager jobQueueManagerToUse)
JobQueueScheduler constructor.

Parameters:
jobQueueManagerToUse - The job queue manager to use.
Method Detail

getJobQueueManager

public static JobQueueManager getJobQueueManager()
Get the job queue manager.

Returns:
JobQueueManager The job queue manager.

setJobQueueManager

public static void setJobQueueManager(JobQueueManager jobQueueManagerToUse)
Set the job queue manager.

Parameters:
jobQueueManagerToUse - The job queue manager to use.

isRunning

public static boolean isRunning()
Check if the job queue scheduler is running.

Returns:
TRUE if the job queue scheduler is running, FALSE otherwise
See Also:
start(), stop()

start

protected void start()
              throws BaseException
Starts the job queue scheduler.

Throws:
BaseException - If the job queue scheduler cannot be started

run

public void run()
Check the database for jobs that are waiting to be executed. We sort the jobs by priority and creation time and try to execute them in that order. Each job is encapsulated in a JobRunner object which is started in it's own thread. Lists jobs in database and adds them to the queue.

Specified by:
run in interface Runnable
Specified by:
run in class TimerTask

runNextJobInQueue

protected void runNextJobInQueue(ManageableJobQueueReadOnlyInterface jobQueue)

stop

protected void stop()
             throws BaseException
Stops the job queue scheduler. If the job queue scheduler is not running this method does nothing.

Throws:
BaseException - If the job queue scheduler cannot be stopped.
See Also:
start(), isRunning()

Last update: 2011-06-23