Package rife.scheduler
Interface TaskManager
- All Known Implementing Classes:
DatabaseTasks,MemoryTasks
public interface TaskManager
This interface defines the methods that classes with
TaskManager functionalities have to implement.- Since:
- 1.0
-
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.
-
Method Details
-
setScheduler
Sets the scheduler that uses this task manager.- Parameters:
scheduler- this task manager's scheduler- Since:
- 1.0
-
getScheduler
Scheduler getScheduler()Retrieves the scheduler of this task manager.- Returns:
- this task manager's scheduler; or
nullif the scheduler hasn't been set - Since:
- 1.0
-
addTask
Adds a new task.After the task addition, the unique ID of the task should be stored in the provided task instance.
- Parameters:
task- the task to add- Returns:
- this unique ID of the added task
- Throws:
TaskManagerException- when an error occurred during the task addition- Since:
- 1.0
-
updateTask
Update an existing task.The task instance should have the unique ID set to be able to update the existing one.
- Parameters:
task- the updated task- Returns:
trueif the task was successfully updated; orfalseotherwise- Throws:
TaskManagerException- when an error occurred during the task update- Since:
- 1.0
-
getTask
Retrieves a task from it's unique ID.- 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- Since:
- 1.0
-
removeTask
Remove a task.- 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- Since:
- 1.0
-
getAllTasks
Retrieves all the tasks that are registered with this task manager.- Returns:
- a collection of all the task manager tasks
- Throws:
TaskManagerException- when an error occurred during the collection of the tasks- Since:
- 1.0
-
getTasksToProcess
Retrieves the tasks that are not busy and that should be processed next by the scheduled based on the current time.- Returns:
- a collection of all the tasks that need to be processed
- Throws:
TaskManagerException- when an error occurred during the collection of the tasks- Since:
- 1.0
-
getScheduledTasks
Retrieves the tasks that are not busy and that are schedule to execute some time in the future.- Returns:
- a collection of all the tasks that are scheduled
- Throws:
TaskManagerException- when an error occurred during the collection of the tasks- Since:
- 1.0
-
rescheduleTask
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.
- 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- Since:
- 1.0
-
activateTask
This method will be called when the scheduler processes a particular task. While being processed, the task should be set asbusy.- 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- Since:
- 1.0
-
deactivateTask
This method will be called when the task is fully done being executed. The task should be set as not busy.- 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- Since:
- 1.0
-
concludeTask
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.- Parameters:
task- the task to conclude- Returns:
- Throws:
TaskManagerException- when an error occurred during the conclusion of the task- Since:
- 1.0
-