net.spy.cron
Class Cron

java.lang.Object
  extended by java.lang.Thread
      extended by net.spy.SpyThread
          extended by net.spy.cron.Cron
All Implemented Interfaces:
java.lang.Runnable

public final class Cron
extends SpyThread

Watches a JobQueue and invokes the Jobs when they're ready.


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
 
Constructor Summary
Cron(JobQueue jq)
          Get a new Cron instance operating on the given queue.
Cron(java.lang.String name, JobQueue jq)
          Get a new Cron instance with a name, JobQueue and the default thread pool.
Cron(java.lang.String name, JobQueue jq, ThreadPool tp)
          Get a new Cron object operating on the given queue.
 
Method Summary
 JobQueue getJobQueue()
          Get the current job queue.
 boolean isRunning()
          True if this Cron instance is still running.
static void main(java.lang.String[] args)
          Run a Cron instance against a FileJobQueue.
 void run()
          Do the run thing.
 void setMaxIdleTime(long maxIdleTime)
          Set the maximum amount of time the cron thread will continue running with no jobs.
 void shutdown()
          Shut down the queue.
 java.lang.String toString()
          String me.
 
Methods inherited from class net.spy.SpyThread
getLogger
 
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, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cron

public Cron(JobQueue jq)
Get a new Cron instance operating on the given queue.

Parameters:
jq - the job queue to watch

Cron

public Cron(java.lang.String name,
            JobQueue jq)
Get a new Cron instance with a name, JobQueue and the default thread pool.

Parameters:
name - name of the cron instance
jq - the queue to watch

Cron

public Cron(java.lang.String name,
            JobQueue jq,
            ThreadPool tp)
Get a new Cron object operating on the given queue.

Parameters:
name - thread name
jq - job queue to watch
tp - the thread pool
Method Detail

toString

public java.lang.String toString()
String me.

Overrides:
toString in class java.lang.Thread

getJobQueue

public JobQueue getJobQueue()
Get the current job queue.


shutdown

public void shutdown()
Shut down the queue.


isRunning

public boolean isRunning()
True if this Cron instance is still running.


run

public void run()
Do the run thing.

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

setMaxIdleTime

public void setMaxIdleTime(long maxIdleTime)
Set the maximum amount of time the cron thread will continue running with no jobs.

Parameters:
maxIdleTime - maximum amount of time in milliseconds

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Run a Cron instance against a FileJobQueue.

Throws:
java.lang.Exception


Copyright © 1995-2005 SPY Internetworking. All Rights Reserved.