Package rife.scheduler.taskmanagers
Class MemoryTasks
java.lang.Object
rife.scheduler.taskmanagers.MemoryTasks
- All Implemented Interfaces:
TaskManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanactivateTask(int id) This method will be called when the scheduler processes a particular task.intAdds a new task.booleanconcludeTask(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.booleandeactivateTask(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.booleanremoveTask(int id) Remove a task.booleanrescheduleTask(Task task, long planned, Frequency frequency) Reschedule an existing task at a particular timestamp.voidsetScheduler(Scheduler scheduler) Sets the scheduler that uses this task manager.booleanupdateTask(Task task) Update an existing task.
-
Constructor Details
-
MemoryTasks
public MemoryTasks()
-
-
Method Details
-
setScheduler
Description copied from interface:TaskManagerSets the scheduler that uses this task manager.- Specified by:
setSchedulerin interfaceTaskManager- Parameters:
scheduler- this task manager's scheduler
-
getScheduler
Description copied from interface:TaskManagerRetrieves the scheduler of this task manager.- Specified by:
getSchedulerin interfaceTaskManager- Returns:
- this task manager's scheduler; or
nullif the scheduler hasn't been set
-
addTask
Description copied from interface:TaskManagerAdds a new task.After the task addition, the unique ID of the task should be stored in the provided task instance.
- Specified by:
addTaskin 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:TaskManagerUpdate an existing task.The task instance should have the unique ID set to be able to update the existing one.
- Specified by:
updateTaskin interfaceTaskManager- Parameters:
task- the updated task- Returns:
trueif the task was successfully updated; orfalseotherwise- Throws:
TaskManagerException- when an error occurred during the task update
-
getTask
Description copied from interface:TaskManagerRetrieves a task from it's unique ID.- Specified by:
getTaskin interfaceTaskManager- Parameters:
id- the unique ID of the task to retrieve- Returns:
- the retrieved task; or
nullif no such task could be found - Throws:
TaskManagerException- when an error occurred during the task retrieval
-
getAllTasks
Description copied from interface:TaskManagerRetrieves all the tasks that are registered with this task manager.- Specified by:
getAllTasksin 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:TaskManagerRetrieves the tasks that are not busy and that should be processed next by the scheduled based on the current time.- Specified by:
getTasksToProcessin 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:TaskManagerRetrieves the tasks that are not busy and that are schedule to execute some time in the future.- Specified by:
getScheduledTasksin 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:TaskManagerRemove a task.- Specified by:
removeTaskin interfaceTaskManager- Parameters:
id- the unique ID of the task to remove- Returns:
trueif the task was successfully removed; orfalseotherwise- 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:TaskManagerReschedule 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:
rescheduleTaskin interfaceTaskManager- Parameters:
task- the task to rescheduleplanned- the planned timestamp in milliseconds since epochfrequency- the new frequency of the task- Returns:
trueif the task was successfully rescheduled; orfalseotherwise- Throws:
TaskManagerException- when an error occurred during the rescheduling of the task
-
concludeTask
Description copied from interface:TaskManagerThis 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:
concludeTaskin 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:TaskManagerThis method will be called when the scheduler processes a particular task. While being processed, the task should be set asbusy.- Specified by:
activateTaskin interfaceTaskManager- Parameters:
id- the unique ID of the task to activate- Returns:
trueif the task was successfully activated; orfalseotherwise- Throws:
TaskManagerException- when an error occurred during the activation of the task
-
deactivateTask
Description copied from interface:TaskManagerThis method will be called when the task is fully done being executed. The task should be set as not busy.- Specified by:
deactivateTaskin interfaceTaskManager- Parameters:
id- the unique ID of the task to deactivate- Returns:
trueif the task was successfully deactivated; orfalseotherwise- Throws:
TaskManagerException- when an error occurred during the deactivation of the task
-