org.openmrs.scheduler
Interface SchedulerService

All Superinterfaces:
OpenmrsService
All Known Implementing Classes:
TimerSchedulerServiceImpl

@Transactional
public interface SchedulerService
extends OpenmrsService

Defines methods required to schedule a task.


Method Summary
 void deleteTask(java.lang.Integer id)
          Delete the task with the given identifier.
 java.util.Collection<TaskDefinition> getRegisteredTasks()
          Get the list of tasks that are available to be scheduled.
 java.util.Collection<TaskDefinition> getScheduledTasks()
          Get scheduled tasks.
 java.lang.String getStatus(java.lang.Integer id)
          Checks the status of a scheduled task.
 java.util.SortedMap<java.lang.String,java.lang.String> getSystemVariables()
          Return SchedulerConstants
 TaskDefinition getTask(java.lang.Integer id)
          Get the task with the given identifier.
 TaskDefinition getTaskByName(java.lang.String name)
          Get the task with the given name.
 void onShutdown()
          Stop all tasks and clean up the scheduler instance.
 void onStartup()
          Start all tasks that are scheduled to run on startup.
 void rescheduleAllTasks()
          Loop over all currently started tasks and cycle them.
 Task rescheduleTask(TaskDefinition task)
          Stop and start a scheduled task.
 void restoreFromMemento(OpenmrsMemento memento)
          Restore the scheduler service to state defined by Memento
 void saveTask(TaskDefinition task)
          Create the given task
 OpenmrsMemento saveToMemento()
          Save the state of the scheduler service to Memento
 Task scheduleTask(TaskDefinition task)
          Start a scheduled task as specified in a TaskDefinition.
 void shutdownTask(TaskDefinition task)
          Cancel a scheduled task.
 

Method Detail

getStatus

@Authorized(value="Manage Scheduler")
java.lang.String getStatus(java.lang.Integer id)
Checks the status of a scheduled task.

Parameters:
id -
Returns:
the String status of the task with the given identifier

onStartup

@Authorized(value="Manage Scheduler")
void onStartup()
Start all tasks that are scheduled to run on startup.

Specified by:
onStartup in interface OpenmrsService

onShutdown

@Authorized(value="Manage Scheduler")
void onShutdown()
Stop all tasks and clean up the scheduler instance.

Specified by:
onShutdown in interface OpenmrsService

shutdownTask

@Authorized(value="Manage Scheduler")
void shutdownTask(TaskDefinition task)
                  throws SchedulerException
Cancel a scheduled task.

Parameters:
task - the TaskDefinition for the task to cancel
Throws:
SchedulerException

scheduleTask

@Authorized(value="Manage Scheduler")
Task scheduleTask(TaskDefinition task)
                  throws SchedulerException
Start a scheduled task as specified in a TaskDefinition.

Parameters:
task - TaskDefinition to start
Returns:
the started Task, or null if there was a problem instantiating or scheduling the task
Throws:
SchedulerException

rescheduleTask

@Authorized(value="Manage Scheduler")
Task rescheduleTask(TaskDefinition task)
                    throws SchedulerException
Stop and start a scheduled task.

Parameters:
task - the TaskDefinition to reschedule
Throws:
SchedulerException

rescheduleAllTasks

@Authorized(value="Manage Scheduler")
void rescheduleAllTasks()
                        throws SchedulerException
Loop over all currently started tasks and cycle them. This should be done after the classloader has been changed (e.g. during module start/stop)

Throws:
SchedulerException

getScheduledTasks

@Authorized(value="Manage Scheduler")
@Transactional(readOnly=true)
java.util.Collection<TaskDefinition> getScheduledTasks()
Get scheduled tasks.

Returns:
all scheduled tasks

getRegisteredTasks

@Authorized(value="Manage Scheduler")
@Transactional(readOnly=true)
java.util.Collection<TaskDefinition> getRegisteredTasks()
Get the list of tasks that are available to be scheduled. Eventually, these should go in the database.

Returns:
all available tasks

getTask

@Authorized(value="Manage Scheduler")
@Transactional(readOnly=true)
TaskDefinition getTask(java.lang.Integer id)
Get the task with the given identifier.

Parameters:
id - the identifier of the task

getTaskByName

@Authorized(value="Manage Scheduler")
@Transactional(readOnly=true)
TaskDefinition getTaskByName(java.lang.String name)
Get the task with the given name.

Parameters:
name - name of the task

deleteTask

@Authorized(value="Manage Scheduler")
void deleteTask(java.lang.Integer id)
Delete the task with the given identifier.

Parameters:
id - the identifier of the task

saveTask

@Authorized(value="Manage Scheduler")
void saveTask(TaskDefinition task)
Create the given task

Parameters:
task - the task to be created
Expected behavior:
save task to the database

getSystemVariables

@Transactional(readOnly=true)
java.util.SortedMap<java.lang.String,java.lang.String> getSystemVariables()
Return SchedulerConstants

Returns:
SortedMap

saveToMemento

OpenmrsMemento saveToMemento()
Save the state of the scheduler service to Memento

Returns:
OpenmrsMemento that contains data about this serive.

restoreFromMemento

void restoreFromMemento(OpenmrsMemento memento)
Restore the scheduler service to state defined by Memento

Parameters:
memento -

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change