Class AbstractTask
java.lang.Object
com.inductiveautomation.ignition.gateway.tasks.AbstractTask
- All Implemented Interfaces:
- Task
This abstract implementation of Task handles some of the complexity of dealing with pausing, cancelling, and
 resuming. Implementations only have to implement doTaskWork(), though they may also implement the state related
 functions to allow for pausing.
- 
Nested Class SummaryNested classes/interfaces inherited from interface com.inductiveautomation.ignition.gateway.tasks.TaskTask.TaskStateModel
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidCan be overridden by sub classes to receive the state model before the task is resumed.voidcancel(long timeoutMS) When called, the task should stop as quickly as possible.protected abstract voiddoTaskWork(TaskContext context) Should execute the work of the task.protected TaskContextgetId()protected LoggerExprotected abstract Stringprotected Optional<Task.TaskStateModel>Can be overridded by sub tasks to provide a state model when the task is suspended.protected booleanvoidresume(Task.TaskStateModel state) final voidrun(TaskContext context) Executes the task.suspend(long timeoutMS) When called, the task should stop as quickly as possible.
- 
Constructor Details- 
AbstractTask
 
- 
- 
Method Details- 
getId
- 
getLoggerName
- 
getLogger
- 
getCurrentContext
- 
isStoppedprotected boolean isStopped()
- 
runDescription copied from interface:TaskExecutes the task. This function should block until completion. If there is a problem executing the task, an exception should be thrown. It is important to note that while this function should block, the task must expect that at some point, suspend or cancel may be called.
- 
suspendpublic Optional<Task.TaskStateModel> suspend(long timeoutMS) throws TimeoutException, InterruptedException Description copied from interface:TaskWhen called, the task should stop as quickly as possible. If the task is able to resume, it should return a state that will be provided to it when restarted. If this function returns an empty value, it will not be resumed. If appropriate, the call should try to implement the timeout restriction passed in. A timeout of 0 means "no timeout".- Specified by:
- suspendin interface- Task
- Throws:
- TimeoutException
- InterruptedException
 
- 
resume
- 
cancelDescription copied from interface:TaskWhen called, the task should stop as quickly as possible. If appropriate, the call should try to implement the timeout restriction passed in. A timeout of 0 means "no timeout".- Specified by:
- cancelin interface- Task
- Throws:
- TimeoutException
- InterruptedException
 
- 
getTaskStateModelCan be overridded by sub tasks to provide a state model when the task is suspended. This will be called after doTaskWork() has exited when the task is "stopped"
- 
applyTaskStateModelCan be overridden by sub classes to receive the state model before the task is resumed. At some point soon after this is called, the doTaskWork() function will be called.
- 
doTaskWorkShould execute the work of the task. It is possible that this function will be called multiple times in the lifecycle of the task. The task may be paused, or the task may choose to yield execution. To yield, it should set its state to "WAITING", and return out of this function. At some point later, it can be resumed by calling resumeTask() on the context, or by the task manager.Inside of this function, the task should periodically check isStopped to see if the task has been paused or canceled. - Throws:
- Exception
 
 
-