org.jcrontab
Class CronTask

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.jcrontab.CronTask
All Implemented Interfaces:
java.lang.Runnable

public class CronTask
extends java.lang.Thread

Implements a runnable task that can be scheduled and executed by the Crontab. If a new kind of task is desired, this class should be extended and the abstract method runTask should be overwritten.

Version:
$Revision: 1.25 $
Author:
$Author: iolalla $

Field Summary
 java.lang.String strClassName
           
 java.lang.String strMethodName
           
 java.lang.String[] strParams
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CronTask()
          Constructor of a task.
CronTask(java.lang.String strClassName, java.lang.String strMethodName, java.lang.String[] strParams)
          Constructor of a task.
 
Method Summary
protected  java.lang.String[] getExtraInfo()
          Returns the aditional parameters given to the task in construction
protected  java.lang.String getMethodName()
          Returns the Method Name given to the task in construction
 void run()
          Runs this task
 void runTask()
          Runs this task.
 void setParams(Crontab cront, int iTaskID, java.lang.String strClassName, java.lang.String strMethodName, java.lang.String[] strExtraInfo)
          Selects the initial parameters for the task.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, 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

strClassName

public java.lang.String strClassName

strMethodName

public java.lang.String strMethodName

strParams

public java.lang.String[] strParams
Constructor Detail

CronTask

public CronTask(java.lang.String strClassName,
                java.lang.String strMethodName,
                java.lang.String[] strParams)
Constructor of a task.

Parameters:
strClassName - Name of the Class
strParams - Parameters for the class or the Method

CronTask

public CronTask()
Constructor of a task. We always call the constructor with no arguments, because the tasks are created dinamically (by Class.forName). You should call the method setParams inmediatly after creating a new task

Method Detail

setParams

public final void setParams(Crontab cront,
                            int iTaskID,
                            java.lang.String strClassName,
                            java.lang.String strMethodName,
                            java.lang.String[] strExtraInfo)
Selects the initial parameters for the task. As a task is created loaded dinamically from the class name, the default constructor called is the one with no arguments. You should call this method after creating the new instance of the task.

Parameters:
cront - The Crontab that creates and executes this task. It should be used to have access to other tasks, in order to wait for them or other tasks operations.
iTaskID - Identifier of the task
strExtraInfo - Extra information given to the task when created

getExtraInfo

protected final java.lang.String[] getExtraInfo()
Returns the aditional parameters given to the task in construction

Returns:
The aditional parameters given to the task in construction

getMethodName

protected final java.lang.String getMethodName()
Returns the Method Name given to the task in construction

Returns:
The aditional parameters given to the task in construction

runTask

public void runTask()
Runs this task. This method does the whole enchilada. This method decides wich method call in the given class


run

public final void run()
Runs this task

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