@Transactional public class TimerSchedulerServiceImpl extends BaseOpenmrsService implements SchedulerService
Constructor and Description |
---|
TimerSchedulerServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
deleteTask(Integer id)
Delete the task with the given identifier.
|
Collection<TaskDefinition> |
getRegisteredTasks()
Get all registered tasks.
|
Collection<TaskDefinition> |
getScheduledTasks()
Get all scheduled tasks.
|
SchedulerDAO |
getSchedulerDAO()
Gets the scheduler data access object.
|
String |
getStatus(Integer id)
Checks the status of a scheduled task.
|
SortedMap<String,String> |
getSystemVariables()
Get system variables.
|
TaskDefinition |
getTask(Integer id)
Get the task with the given identifier.
|
TaskDefinition |
getTaskByName(String name)
Get the task with the given name.
|
TaskDefinition |
getTaskByUuid(String uuid) |
void |
onShutdown()
Shutdown hook for the scheduler and all of its scheduled tasks.
|
void |
onStartup()
Start up hook for the scheduler and all of its scheduled tasks.
|
void |
registerTask(TaskDefinition definition)
Register a new task by adding it to our task map with an empty schedule map.
|
void |
rescheduleAllTasks()
Loop over all currently started tasks and cycle them.
|
Task |
rescheduleTask(TaskDefinition taskDefinition)
Stop and start a scheduled task.
|
void |
restoreFromMemento(OpenmrsMemento memento)
Restore the scheduler service to state defined by Memento
|
void |
saveTaskDefinition(TaskDefinition task)
Save a task in the database.
|
OpenmrsMemento |
saveToMemento()
Saves and stops all active tasks
|
void |
scheduleIfNotRunning(TaskDefinition taskDef)
Schedules a task for execution if not already running
|
Task |
scheduleTask(TaskDefinition taskDefinition)
Schedule the given task according to the given schedule.
|
static void |
setScheduledTasks(Map<Integer,TimerSchedulerTask> scheduledTasks) |
void |
setSchedulerDAO(SchedulerDAO dao)
Sets the scheduler data access object.
|
void |
shutdownAllTasks()
Shutdown all running tasks.
|
void |
shutdownTask(TaskDefinition taskDefinition)
Stops a running task.
|
public SchedulerDAO getSchedulerDAO()
public void setSchedulerDAO(SchedulerDAO dao)
public void onStartup()
onStartup
in interface OpenmrsService
onStartup
in interface SchedulerService
onStartup
in class BaseOpenmrsService
OpenmrsService.onStartup()
public static void setScheduledTasks(Map<Integer,TimerSchedulerTask> scheduledTasks)
public void onShutdown()
onShutdown
in interface OpenmrsService
onShutdown
in interface SchedulerService
onShutdown
in class BaseOpenmrsService
OpenmrsService.onShutdown()
public void shutdownAllTasks()
public Task scheduleTask(TaskDefinition taskDefinition) throws SchedulerException
scheduleTask
in interface SchedulerService
taskDefinition
- the task to be scheduled
Should should handle zero repeat intervalTask
, or null if there was a problem instantiating or
scheduling the taskSchedulerException
public void shutdownTask(TaskDefinition taskDefinition) throws SchedulerException
shutdownTask
in interface SchedulerService
taskDefinition
- the task to be stoppedSchedulerException
SchedulerService.shutdownTask(TaskDefinition)
public void rescheduleAllTasks() throws SchedulerException
rescheduleAllTasks
in interface SchedulerService
SchedulerException
public Task rescheduleTask(TaskDefinition taskDefinition) throws SchedulerException
SchedulerService
rescheduleTask
in interface SchedulerService
taskDefinition
- the TaskDefinition
to rescheduleSchedulerException
SchedulerService.rescheduleTask(org.openmrs.scheduler.TaskDefinition)
public void registerTask(TaskDefinition definition)
definition
- task to registerpublic Collection<TaskDefinition> getScheduledTasks()
getScheduledTasks
in interface SchedulerService
@Transactional(readOnly=true) public Collection<TaskDefinition> getRegisteredTasks()
getRegisteredTasks
in interface SchedulerService
@Transactional(readOnly=true) public TaskDefinition getTask(Integer id)
getTask
in interface SchedulerService
id
- the identifier of the task@Transactional(readOnly=true) public TaskDefinition getTaskByName(String name)
getTaskByName
in interface SchedulerService
name
- name of the taskpublic void saveTaskDefinition(TaskDefinition task)
saveTaskDefinition
in interface SchedulerService
task
- the TaskDefinition
to savepublic void deleteTask(Integer id)
deleteTask
in interface SchedulerService
id
- the identifier of the taskpublic SortedMap<String,String> getSystemVariables()
getSystemVariables
in interface SchedulerService
public OpenmrsMemento saveToMemento()
saveToMemento
in interface SchedulerService
public void restoreFromMemento(OpenmrsMemento memento)
SchedulerService
restoreFromMemento
in interface SchedulerService
public String getStatus(Integer id)
SchedulerService
getStatus
in interface SchedulerService
String
status of the task with the given identifierTODO
internationalization of string status messages
public void scheduleIfNotRunning(TaskDefinition taskDef)
SchedulerService
scheduleIfNotRunning
in interface SchedulerService
@Transactional(readOnly=true) public TaskDefinition getTaskByUuid(String uuid)
getTaskByUuid
in interface SchedulerService
uuid
- the unique identifier of the taskSchedulerService.getTaskByUuid(java.lang.String)
Copyright © 2024 OpenMRS Inc.. All rights reserved.