planetj.util
Class TaskScheduler

java.lang.Object
  |
  +--planetj.util.TaskScheduler

public class TaskScheduler
extends Object

Author:
PlanetJ Corporation

Constructor Summary
TaskScheduler()
          TaskScheduler constructor comment.
TaskScheduler(boolean pCreateDefaultTimer)
          TaskScheduler constructor comment.
TaskScheduler(boolean pCreateDefaultTimer, boolean pIsDaemon)
          TaskScheduler constructor comment.
 
Method Summary
 void addTimer(CMTimer pTimer)
          Adds the specified timer to this TaskScheduler to be used for scheduling task.
 void cancelTimer(CMTimer pTimer)
          Cancels and removes the specified timer from this TaskScheduler.
 void cancelTimer(String pTimerKey)
          Cancels and removes the timer with the specified key from this TaskScheduler.
 CMTimer createTimer(String pTimerKey)
          Creates and returns a timer.
 CMTimer createTimer(String pTimerKey, boolean pIsDaemon)
          Creates a new timer if one does not exist for the specified key.
 CMTimer getDefaultTimer()
          Returns the default timer for this scheduler that may be used to schedule tasks.
 String getDefaultTimerKey()
          Returns the key for the default timer.
 CMTimer getTimer(String pKey)
          Return the timer identified by the given key.
 int getTimerCount()
          Returns the number of timers managed by this TaskScheduler.
 void removeTimer(CMTimer pTimer)
          Removes the specified timer from this TaskScheduler.
 void removeTimer(String pTimerKey)
          Removes the specified timer from this TaskScheduler.
 void schedule(String pTimerKey, CMTimerTask pTask, Date pTime)
          Schedules the task using the timer for the given key.
 void schedule(String pTimerKey, CMTimerTask pTask, Date pFirstTime, long pPeriod)
          Schedule the task in the timer for the given key.
 void schedule(String pTimerKey, CMTimerTask pTask, long pDelay)
          Schedules the task in the timer for the given key.
 void schedule(String pTimerKey, CMTimerTask pTask, long pDelay, long pPeriod)
          Schedules the task in the timer for the given key.
 void scheduleAtFixedRate(String pTimerKey, CMTimerTask pTask, Date pFirstTime, long pPeriod)
          Schedules the task in the timer for the specified key.
 void scheduleAtFixedRate(String pTimerKey, CMTimerTask pTask, long pDelay, long pPeriod)
          Schedules the task in the timer for the specified key.
 void setDefaultTimer(CMTimer pTimer)
          Sets the key for the default timer to the id of the specified timer.
 void setDefaultTimerKey(String pDefaultTimerKey)
          Sets the key for the default timer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskScheduler

public TaskScheduler()
TaskScheduler constructor comment.


TaskScheduler

public TaskScheduler(boolean pCreateDefaultTimer)
TaskScheduler constructor comment.

Parameters:
pCreateDefaultTimer - boolean

TaskScheduler

public TaskScheduler(boolean pCreateDefaultTimer,
                     boolean pIsDaemon)
TaskScheduler constructor comment.

Parameters:
pCreateDefaultTimer - boolean
pIsDaemon - boolean
Method Detail

addTimer

public void addTimer(CMTimer pTimer)
Adds the specified timer to this TaskScheduler to be used for scheduling task.

Parameters:
pTimer - timer to add to this scheduler.

cancelTimer

public void cancelTimer(String pTimerKey)
Cancels and removes the timer with the specified key from this TaskScheduler.

Parameters:
pTimerKey - key fo the timer to cancel and remove from this scheduler.
See Also:
Timer.cancel()

cancelTimer

public void cancelTimer(CMTimer pTimer)
Cancels and removes the specified timer from this TaskScheduler.

Parameters:
pTimer - timer to cancel and remove from this scheduler.
See Also:
Timer.cancel()

createTimer

public CMTimer createTimer(String pTimerKey)
Creates and returns a timer.

Returns:
The timer created.

createTimer

public CMTimer createTimer(String pTimerKey,
                           boolean pIsDaemon)
Creates a new timer if one does not exist for the specified key.

Parameters:
pIsDaemon - boolean
Returns:
The timer created.

getDefaultTimer

public CMTimer getDefaultTimer()
Returns the default timer for this scheduler that may be used to schedule tasks.

Returns:
The default timer.

getDefaultTimerKey

public String getDefaultTimerKey()
Returns the key for the default timer.

Returns:
The key for the default timer.

getTimer

public CMTimer getTimer(String pKey)
Return the timer identified by the given key.

Returns:
A timer identified by the given key.

getTimerCount

public int getTimerCount()
Returns the number of timers managed by this TaskScheduler.

Returns:
The number of timers managed by this TaskScheduler.

removeTimer

public void removeTimer(String pTimerKey)
Removes the specified timer from this TaskScheduler.

Parameters:
pTimerKey - key of the timer to remove from this scheduler.

removeTimer

public void removeTimer(CMTimer pTimer)
Removes the specified timer from this TaskScheduler.

Parameters:
pTimer - timer to be removed from this scheduler.

schedule

public void schedule(String pTimerKey,
                     CMTimerTask pTask,
                     long pDelay)
              throws NoSuchTimerException
Schedules the task in the timer for the given key.

Parameters:
pTimerKey - timer to use to schedule the task (if null, the default timer is used).
pTask - task to be scheduled.
pDelay - delay in milliseconds before task is to be executed.
NoSuchTimerException
See Also:
Timer.schedule(java.util.TimerTask, long)

schedule

public void schedule(String pTimerKey,
                     CMTimerTask pTask,
                     long pDelay,
                     long pPeriod)
              throws NoSuchTimerException
Schedules the task in the timer for the given key.

Parameters:
pTimerKey - timer to use to schedule the task (if null, the default timer is used).
pTask - task to be scheduled.
pDelay - delay in milliseconds before task is to be executed.
pPeriod - time in milliseconds between successive task executions.
NoSuchTimerException
See Also:
Timer.schedule(java.util.TimerTask, long, long)

schedule

public void schedule(String pTimerKey,
                     CMTimerTask pTask,
                     Date pTime)
              throws NoSuchTimerException
Schedules the task using the timer for the given key.

Parameters:
pTimerKey - timer to use to schedule the task (if null, the default timer is used).
pTask - task to be scheduled.
pTime - time at which task is to be executed.
NoSuchTimerException
See Also:
Timer.schedule(java.util.TimerTask, java.util.Date)

schedule

public void schedule(String pTimerKey,
                     CMTimerTask pTask,
                     Date pFirstTime,
                     long pPeriod)
              throws NoSuchTimerException
Schedule the task in the timer for the given key.

Parameters:
pTimerKey - timer to use to schedule the task (if null, the default timer is used).
pTask - task to be scheduled.
pFirstTime - First time at which task is to be executed.
pPeriod - time in milliseconds between successive task executions.
NoSuchTimerException
See Also:
Timer.schedule(java.util.TimerTask, java.util.Date, long)

scheduleAtFixedRate

public void scheduleAtFixedRate(String pTimerKey,
                                CMTimerTask pTask,
                                long pDelay,
                                long pPeriod)
                         throws NoSuchTimerException
Schedules the task in the timer for the specified key.

Parameters:
pTimerKey - timer to use to schedule the task (if null, the default timer is used).
pTask - task to be scheduled.
pDelay - delay in milliseconds before task is to be executed.
pPeriod - time in milliseconds between successive task executions.
NoSuchTimerException
See Also:
Timer.schedule(java.util.TimerTask, long, long)

scheduleAtFixedRate

public void scheduleAtFixedRate(String pTimerKey,
                                CMTimerTask pTask,
                                Date pFirstTime,
                                long pPeriod)
                         throws NoSuchTimerException
Schedules the task in the timer for the specified key.

Parameters:
pTimerKey - timer to use to schedule the task (if null, the default timer is used).
pTask - task to be scheduled.
pFirstTime - First time at which task is to be executed.
pPeriod - time in milliseconds between successive task executions.
NoSuchTimerException
See Also:
Timer.schedule(java.util.TimerTask, java.util.Date, long)

setDefaultTimer

public void setDefaultTimer(CMTimer pTimer)
Sets the key for the default timer to the id of the specified timer. If the timer is not part of this TaskScheduler, then it is added.

Parameters:
pTimer - The timer to use as the default.

setDefaultTimerKey

public void setDefaultTimerKey(String pDefaultTimerKey)
Sets the key for the default timer.

Parameters:
pDefaultTimerKey - The key for the default timer.