com.dvt.app.threadworks
Class Scheduler

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.dvt.app.threadworks.Scheduler
All Implemented Interfaces:
java.lang.Runnable

public class Scheduler
extends java.lang.Thread

A Java-based scheduler. Scheduler supports time-based dependencies and custom dependancies. Any task that is runnable can be scheduled.

Internally, Scheduler uses a TaskManager(@see TaskManager). Therefore, it benefits from the support infrastructure that TaskManager provides.

Only one Scheduler per JVM is allowed. If a custom environment for Scheduler is needed, place the Scheduler instantiation in the start-up sequence of your application BEFORE and Schedulers and TaskManagers are defined.

It is recommended, but not required, that scheduled tasks implement Describable (@see com.dvt.app.common.Describable) as well as Runnable. Describables are capable of producing textual descriptions of themselves. If the task excepts or exceeds its maximum allowed run time, Scheduler will log the probleem. If the task is Describable, Scheduler will log the tasks description as well. This facilitates support.

Copyright: Delta Vortex Technologies, 2001.


Field Summary
static long DAILY_INTERVAL
          Daily interval
static int DEFAULT_DIAGNOSTIC_REPORTING_INTERVAL
          Default interval for reporting diagnostics in milliseconds.
static java.lang.String DEFAULT_LOG_LABEL
          Default log label
static int DEFAULT_MAX_TASK_TIME_ALLOWED
          Default maximum time allowed on 1 task in milliseconds.
static int DEFAULT_NBR_CONCURRENT_TASKS
          Default number of concurrent scheduled tasks
static java.lang.String DEFAULT_PROP_FILE_NAME
          Default properties file name
static long DEFAULT_SPIN_COUNT
          Default spin count
static long HOURLY_INTERVAL
          Hourly Interval
static long WEEKLY_INTERVAL
          Weekly Interval
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Scheduler(java.lang.String propertiesFileName)
          Starts the Scheduler with a custom environment.
Scheduler(TaskManagerEnvironment env, long spinCount)
          Starts the Scheduler with a custom environment.
 
Method Summary
static void logDiagnostics()
          Will log Scheduler diagnostics.
static boolean remove(java.lang.Runnable task)
          Removes a previously scheduled task
static boolean remove(java.lang.Runnable task, long interval)
          Removes a previously scheduled task
 void run()
          Used internally by the Scheduler.
static void schedule(java.lang.Runnable task, java.util.GregorianCalendar dateTime)
          Schedules a one-time task execution starting at the specified date and time.
static void schedule(java.lang.Runnable task, java.util.GregorianCalendar dateTime, DependencyEventListener listener)
          Schedules a one-time task execution starting at the specified date and time.
static void schedule(java.lang.Runnable task, java.util.GregorianCalendar dateTime, long interval)
          Schedules a recurring task starting at the specified date and time.
static void schedule(java.lang.Runnable task, java.util.GregorianCalendar dateTime, long interval, DependencyEventListener listener)
          Schedules a recurring task starting at the specified date and time.
static void schedule(java.lang.Runnable task, long delay)
          Schedules a one-time execution of a task starting after an initial delay.
static void schedule(java.lang.Runnable task, long delay, DependencyEventListener listener)
          Schedules a one-time execution of a task starting after an initial delay.
static void schedule(java.lang.Runnable task, long delay, long interval)
          Schedules a recurring task starting after an initial delay.
static void schedule(java.lang.Runnable task, long delay, long interval, DependencyEventListener listener)
          Schedules a recurring task starting after an initial delay.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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
 

Field Detail

DEFAULT_SPIN_COUNT

public static final long DEFAULT_SPIN_COUNT
Default spin count

DEFAULT_PROP_FILE_NAME

public static final java.lang.String DEFAULT_PROP_FILE_NAME
Default properties file name

DEFAULT_NBR_CONCURRENT_TASKS

public static final int DEFAULT_NBR_CONCURRENT_TASKS
Default number of concurrent scheduled tasks

DEFAULT_DIAGNOSTIC_REPORTING_INTERVAL

public static final int DEFAULT_DIAGNOSTIC_REPORTING_INTERVAL
Default interval for reporting diagnostics in milliseconds.

DEFAULT_MAX_TASK_TIME_ALLOWED

public static final int DEFAULT_MAX_TASK_TIME_ALLOWED
Default maximum time allowed on 1 task in milliseconds.

DEFAULT_LOG_LABEL

public static final java.lang.String DEFAULT_LOG_LABEL
Default log label

HOURLY_INTERVAL

public static final long HOURLY_INTERVAL
Hourly Interval

DAILY_INTERVAL

public static final long DAILY_INTERVAL
Daily interval

WEEKLY_INTERVAL

public static final long WEEKLY_INTERVAL
Weekly Interval
Constructor Detail

Scheduler

public Scheduler(java.lang.String propertiesFileName)
          throws ThreadWorksException
Starts the Scheduler with a custom environment.
Parameters:
Properties -  

Scheduler

public Scheduler(TaskManagerEnvironment env,
                 long spinCount)
          throws ThreadWorksException
Starts the Scheduler with a custom environment.
Parameters:
Environment - for internal TaskManager
time - interval in millis that the schedule is examined.
Method Detail

run

public void run()
Used internally by the Scheduler.
Overrides:
run in class java.lang.Thread

schedule

public static void schedule(java.lang.Runnable task,
                            long delay)
                     throws ThreadWorksException
Schedules a one-time execution of a task starting after an initial delay.
Parameters:
task - to be scheduled
run - delay in millis

schedule

public static void schedule(java.lang.Runnable task,
                            long delay,
                            DependencyEventListener listener)
                     throws ThreadWorksException
Schedules a one-time execution of a task starting after an initial delay.
Parameters:
task - to be scheduled
run - delay in millis
dependency - listener

schedule

public static void schedule(java.lang.Runnable task,
                            long delay,
                            long interval)
                     throws ThreadWorksException
Schedules a recurring task starting after an initial delay.
Parameters:
task - to be scheduled
initial - run delay in millis
run - interval used after initial run

schedule

public static void schedule(java.lang.Runnable task,
                            long delay,
                            long interval,
                            DependencyEventListener listener)
                     throws ThreadWorksException
Schedules a recurring task starting after an initial delay.
Parameters:
task - to be scheduled
initial - run delay in millis
run - interval used after initial run
dependency - listener

schedule

public static void schedule(java.lang.Runnable task,
                            java.util.GregorianCalendar dateTime)
                     throws ThreadWorksException
Schedules a one-time task execution starting at the specified date and time.
Parameters:
task - to be scheduled
date - and time of initial run

schedule

public static void schedule(java.lang.Runnable task,
                            java.util.GregorianCalendar dateTime,
                            DependencyEventListener listener)
                     throws ThreadWorksException
Schedules a one-time task execution starting at the specified date and time.
Parameters:
task - to be scheduled
date - and time of initial run
dependency - listener

schedule

public static void schedule(java.lang.Runnable task,
                            java.util.GregorianCalendar dateTime,
                            long interval)
                     throws ThreadWorksException
Schedules a recurring task starting at the specified date and time.
Parameters:
task - to be scheduled
date - and time of initial run
run - interval used after initial run

schedule

public static void schedule(java.lang.Runnable task,
                            java.util.GregorianCalendar dateTime,
                            long interval,
                            DependencyEventListener listener)
                     throws ThreadWorksException
Schedules a recurring task starting at the specified date and time.
Parameters:
task - to be scheduled
date - and time of initial run
run - interval used after initial run
dependency - listener

remove

public static boolean remove(java.lang.Runnable task)
                      throws ThreadWorksException
Removes a previously scheduled task
Parameters:
task - to be removed
Returns:
indicator if a scheduled task was removed.

remove

public static boolean remove(java.lang.Runnable task,
                             long interval)
                      throws ThreadWorksException
Removes a previously scheduled task
Parameters:
task - to be removed
interval - used in original scheduling
Returns:
indicator if scheduled task at specified interval was removed

logDiagnostics

public static void logDiagnostics()
                           throws ThreadWorksException
Will log Scheduler diagnostics.


Copyright © 2001 Delta Vortex Technologies, Inc. All Rights Reserved.