org.jcrontab
Class Crontab

java.lang.Object
  |
  +--org.jcrontab.Crontab

public class Crontab
extends java.lang.Object

Manages the creation and execution of all the scheduled tasks of jcrontab. This class is the core of the jcrontab

Version:
$Revision: 1.46 $
Author:
$Author: iolalla $

Method Summary
 boolean deleteTask(int iTaskID)
          Removes a task from the internal arrays of active tasks.
 CronTask[] getAllTasks()
          Returns an array with all active tasks
static Crontab getInstance()
          Returns the only instance of this class we've choosen a singleton pattern to avoid launch different Crontab If you need diferent crontab classes to be launched only should Change the private constructor to public.
 java.lang.String getProperty(java.lang.String property)
          This method gets the value of the given property
 void init()
          Initializes the crontab, reading task table from configuration file
 void init(java.util.Properties props)
          Used by the loadCrontabServlet to start Crontab with the configuration passed in a Properties object.
 void init(java.lang.String strFileName)
          Initializes the crontab, reading task table from configuration file
 int newTask(java.lang.String strClassName, java.lang.String strMethodName, java.lang.String[] strExtraInfo)
          Creates and runs a new task
 void setProperty(java.lang.String property, java.lang.String value)
          This method sets the given property
 void storeProperty(java.lang.String property, java.lang.String value)
          This method Stores in the properties File the given property and all the "live" properties
 void uninit()
          UnInitializes the Crontab.
 void uninit(int iSecondsToWait)
          UnInitializes the crontab.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Crontab getInstance()
Returns the only instance of this class we've choosen a singleton pattern to avoid launch different Crontab If you need diferent crontab classes to be launched only should Change the private constructor to public.

Returns:
singleton the only instance of this class

init

public void init()
          throws java.lang.Exception
Initializes the crontab, reading task table from configuration file

Throws:
java.lang.Exception

init

public void init(java.lang.String strFileName)
          throws java.lang.Exception
Initializes the crontab, reading task table from configuration file

Parameters:
strFileName - Name of the tasks configuration file
Throws:
java.lang.Exception

init

public void init(java.util.Properties props)
          throws java.lang.Exception
Used by the loadCrontabServlet to start Crontab with the configuration passed in a Properties object.

Parameters:
props - a Properties object
Throws:
java.lang.Exception

uninit

public void uninit()
UnInitializes the Crontab. Calls to the method stopInTheNextMinute() of the Cron.


uninit

public void uninit(int iSecondsToWait)
UnInitializes the crontab. Calls to the method join() of each of the tasks running.

Parameters:
iSecondsToWait - Number of seconds to wait for the tasks to end their process before returning from this method

getProperty

public java.lang.String getProperty(java.lang.String property)
This method gets the value of the given property

Parameters:
property -
Returns:
value

setProperty

public void setProperty(java.lang.String property,
                        java.lang.String value)
This method sets the given property

Parameters:
property -
value -

storeProperty

public void storeProperty(java.lang.String property,
                          java.lang.String value)
This method Stores in the properties File the given property and all the "live" properties

Parameters:
property -
value -

newTask

public int newTask(java.lang.String strClassName,
                   java.lang.String strMethodName,
                   java.lang.String[] strExtraInfo)
Creates and runs a new task

Parameters:
strClassName - Name of the task
strMethodName - Name of the method that will be called
strExtraInfo - Extra Information given to the task
Returns:
The identifier of the new task created, or -1 if could not create the new task (maximum number of tasks exceeded or another error)

deleteTask

public boolean deleteTask(int iTaskID)
Removes a task from the internal arrays of active tasks. This method is called from method run() of CronTask when a task has finished.

Parameters:
iTaskID - Identifier of the task to delete
Returns:
true if the task was deleted correctly, false otherwise

getAllTasks

public CronTask[] getAllTasks()
Returns an array with all active tasks

Returns:
An array with all active tasks NOTE: Does not returns the internal array because it is synchronized, returns a copy of it.