Package rife.scheduler.taskmanagers
Class MemoryTasks
java.lang.Object
rife.scheduler.taskmanagers.MemoryTasks
- All Implemented Interfaces:
TaskManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
activateTask
(int id) This method will be called when the scheduler processes a particular task.int
Adds a new task.boolean
concludeTask
(Task task) This method will be called by the scheduler when the task has done processing, any resources should be cleaned up and any task rescheduling, removal or deactivation should be done by the manager here.boolean
deactivateTask
(int id) This method will be called when the task is fully done being executed.Retrieves all the tasks that are registered with this task manager.Retrieves the tasks that are not busy and that are schedule to execute some time in the future.Retrieves the scheduler of this task manager.getTask
(int id) Retrieves a task from it's unique ID.Retrieves the tasks that are not busy and that should be processed next by the scheduled based on the current time.boolean
removeTask
(int id) Remove a task.boolean
rescheduleTask
(Task task, long planned, Frequency frequency) Reschedule an existing task at a particular timestamp.void
setScheduler
(Scheduler scheduler) Sets the scheduler that uses this task manager.boolean
updateTask
(Task task) Update an existing task.
-
Constructor Details
-
MemoryTasks
public MemoryTasks()
-
-
Method Details
-
setScheduler
Description copied from interface:TaskManager
Sets the scheduler that uses this task manager.- Specified by:
setScheduler
in interfaceTaskManager
- Parameters:
scheduler
- this task manager's scheduler
-
getScheduler
Description copied from interface:TaskManager
Retrieves the scheduler of this task manager.- Specified by:
getScheduler
in interfaceTaskManager
- Returns:
- this task manager's scheduler; or
null
if the scheduler hasn't been set
-
addTask
Description copied from interface:TaskManager
Adds a new task.After the task addition, the unique ID of the task should be stored in the provided task instance.
- Specified by:
addTask
in interfaceTaskManager
- Parameters:
task
- the task to add- Returns:
- this unique ID of the added task
- Throws:
TaskManagerException
- when an error occurred during the task addition
-
updateTask
Description copied from interface:TaskManager
Update an existing task.The task instance should have the unique ID set to be able to update the existing one.
- Specified by:
updateTask
in interfaceTaskManager
- Parameters:
task
- the updated task- Returns:
true
if the task was successfully updated; orfalse
otherwise- Throws:
TaskManagerException
- when an error occurred during the task update
-
getTask
Description copied from interface:TaskManager
Retrieves a task from it's unique ID.- Specified by:
getTask
in interfaceTaskManager
- Parameters:
id
- the unique ID of the task to retrieve- Returns:
- the retrieved task; or
null
if no such task could be found - Throws:
TaskManagerException
- when an error occurred during the task retrieval
-
getAllTasks
Description copied from interface:TaskManager
Retrieves all the tasks that are registered with this task manager.- Specified by:
getAllTasks
in interfaceTaskManager
- Returns:
- a collection of all the task manager tasks
- Throws:
TaskManagerException
- when an error occurred during the collection of the tasks
-
getTasksToProcess
Description copied from interface:TaskManager
Retrieves the tasks that are not busy and that should be processed next by the scheduled based on the current time.- Specified by:
getTasksToProcess
in interfaceTaskManager
- Returns:
- a collection of all the tasks that need to be processed
- Throws:
TaskManagerException
- when an error occurred during the collection of the tasks
-
getScheduledTasks
Description copied from interface:TaskManager
Retrieves the tasks that are not busy and that are schedule to execute some time in the future.- Specified by:
getScheduledTasks
in interfaceTaskManager
- Returns:
- a collection of all the tasks that are scheduled
- Throws:
TaskManagerException
- when an error occurred during the collection of the tasks
-
removeTask
Description copied from interface:TaskManager
Remove a task.- Specified by:
removeTask
in interfaceTaskManager
- Parameters:
id
- the unique ID of the task to remove- Returns:
true
if the task was successfully removed; orfalse
otherwise- Throws:
TaskManagerException
- when an error occurred during the task removal
-
rescheduleTask
public boolean rescheduleTask(Task task, long planned, Frequency frequency) throws TaskManagerException Description copied from interface:TaskManager
Reschedule an existing task at a particular timestamp.This method will also change the task instance that's provided.
The task instance should have the unique ID set to be able to update the existing one.
- Specified by:
rescheduleTask
in interfaceTaskManager
- Parameters:
task
- the task to rescheduleplanned
- the planned timestamp in milliseconds since epochfrequency
- the new frequency of the task- Returns:
true
if the task was successfully rescheduled; orfalse
otherwise- Throws:
TaskManagerException
- when an error occurred during the rescheduling of the task
-
concludeTask
Description copied from interface:TaskManager
This method will be called by the scheduler when the task has done processing, any resources should be cleaned up and any task rescheduling, removal or deactivation should be done by the manager here.- Specified by:
concludeTask
in interfaceTaskManager
- Parameters:
task
- the task to conclude- Returns:
- Throws:
TaskManagerException
- when an error occurred during the conclusion of the task
-
activateTask
Description copied from interface:TaskManager
This method will be called when the scheduler processes a particular task. While being processed, the task should be set asbusy
.- Specified by:
activateTask
in interfaceTaskManager
- Parameters:
id
- the unique ID of the task to activate- Returns:
true
if the task was successfully activated; orfalse
otherwise- Throws:
TaskManagerException
- when an error occurred during the activation of the task
-
deactivateTask
Description copied from interface:TaskManager
This method will be called when the task is fully done being executed. The task should be set as not busy.- Specified by:
deactivateTask
in interfaceTaskManager
- Parameters:
id
- the unique ID of the task to deactivate- Returns:
true
if the task was successfully deactivated; orfalse
otherwise- Throws:
TaskManagerException
- when an error occurred during the deactivation of the task
-