Class ScheduledTask
public no-argument constructor.
Life cycle
A ScheduledTask is instantiated each time a task definition is validated by EBX®
and each time the execution is fired by the scheduler.
Configuration
A ScheduledTask can be parameterized using JavaBean specifications (getters and setters).
Supported parameter types are:
- boolean
- int
- java.lang.Boolean
- java.lang.Integer
- java.math.BigDecimal
- java.lang.String
- java.util.Date
- java.net.URI
- java.net.URL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidexecute(ScheduledExecutionContext aContext) Executes the current task.voidWhen a task interruption has been requested through EBX® administration, this method provides the opportunity to perform actions before actually interrupting the task execution.voidhandleBeforePausing(ScheduledExecutionContext aContext) When a pause has been requested through EBX® administration, this method provides the opportunity to perform actions before entering the pause state.voidWhen the administrator requests to resume a paused schedule task, this method provides the opportunity to perform actions before the task resumes execution.booleanIftrue, the current task can be interrupted through EBX® administration.booleanIftrue, the current task can be paused (and resumed) through EBX® administration.voidvalidate(ValueContextForValidation aValidationContext) Validates the current task configuration.
-
Constructor Details
-
ScheduledTask
public ScheduledTask()
-
-
Method Details
-
validate
Validates the current task configuration.Called at:
- task configuration in Administration > Task scheduler > Tasks,
- task instantiation in the scheduler.
Default implementation does nothing. To be overridden if specific checks have to be done.
-
execute
public abstract void execute(ScheduledExecutionContext aContext) throws OperationException, ScheduledTaskInterruption Executes the current task.The implementation of this method should not try to catch the interruption signal
ScheduledTaskInterruption.- Throws:
OperationExceptionScheduledTaskInterruption- See Also:
-
handleBeforeInterrupting
When a task interruption has been requested through EBX® administration, this method provides the opportunity to perform actions before actually interrupting the task execution.For instance, this may be overridden to release resources by closing open files and database connections.
In order to enable interruptions, the method
isInterruptable()must be overridden. Also, to allow interrupting, the execution method must invoke the methodScheduledExecutionContext.handleExecutionState()where an interrupt would be acceptable.Default implementation does nothing.
-
handleBeforePausing
When a pause has been requested through EBX® administration, this method provides the opportunity to perform actions before entering the pause state.For instance, this may be overridden to release resources by closing open files and database connections.
In order to enable pauses, the method
isPausable()must be overridden. Also, to allow pausing, the execution method must invoke the methodScheduledExecutionContext.handleExecutionState()where a pause would be acceptable.Default implementation does nothing. If an
OperationExceptionis thrown, the task execution is interrupted.- Throws:
OperationException- See Also:
-
handleBeforeResuming
When the administrator requests to resume a paused schedule task, this method provides the opportunity to perform actions before the task resumes execution.For instance, this may be overridden to acquire resources that were released after the pause by re-opening files and JDBC connections.
If an
OperationExceptionis thrown, the task execution is interrupted.Default implementation does nothing. To be overridden if a specific behavior is required.
- Throws:
OperationException- See Also:
-
isInterruptable
public boolean isInterruptable()Iftrue, the current task can be interrupted through EBX® administration.Default implementation returns
false. -
isPausable
public boolean isPausable()Iftrue, the current task can be paused (and resumed) through EBX® administration.Default implementation returns
false.
-