it.sauronsoftware.cron4j
Interface TaskExecutionContext


public interface TaskExecutionContext

A TaskExecutionContext object provides support methods for the execution of a task. An instance of this class is always passed to the task when its Task.execute(TaskExecutionContext) method is called. The task, while executing, can use the received context to exchange informations with its own executor. If the task declares to supports pausing, stopping, completeness tracking and/or status tracking, it has to use its context methods to perform any declared operation (checks pause and stop requests, sends back tracking informations).

Since:
2.0
Author:
Carlo Pelliccia

Method Summary
 Scheduler getScheduler()
          Returns the scheduler.
 TaskExecutor getTaskExecutor()
          Returns the task executor.
 boolean isStopped()
          Checks whether the task execution has been demanded to be stopped.
 void pauseIfRequested()
          If the task execution has been paused, stops until the operation is resumed.
 void setCompleteness(double completeness)
          Sets the completeness tracking value, that has to be between 0 and 1.
 void setStatusMessage(java.lang.String message)
          Sets the current status tracking message, that has to be something about what the task is doing at the moment.
 

Method Detail

getScheduler

Scheduler getScheduler()
Returns the scheduler.

Returns:
The scheduler.

getTaskExecutor

TaskExecutor getTaskExecutor()
Returns the task executor.

Returns:
The task executor.

setStatusMessage

void setStatusMessage(java.lang.String message)
Sets the current status tracking message, that has to be something about what the task is doing at the moment.

Parameters:
message - A message representing the current execution status. Null messages will be blanked.

setCompleteness

void setCompleteness(double completeness)
Sets the completeness tracking value, that has to be between 0 and 1.

Parameters:
completeness - A completeness value, between 0 and 1. Values out of range will be ignored.

pauseIfRequested

void pauseIfRequested()
If the task execution has been paused, stops until the operation is resumed. It can also returns because of a stop operation without any previous resuming. Due to this the task developer should always check the isStopped() value after any pauseIfRequested() call. Note that a task execution can be paused only if the task Task.canBePaused() method returns true.


isStopped

boolean isStopped()
Checks whether the task execution has been demanded to be stopped. If the returned value is true, the task developer must shut down gracefully its task execution, as soon as possible. Note that a task execution can be stopped only if the task Task.canBePaused() method returns true.

Returns:
true if the current task execution has been demanded to be stopped; false otherwise.