Class ScheduledTask
- java.lang.Object
-
- com.orchestranetworks.scheduler.ScheduledTask
-
public abstract class ScheduledTask extends Object
Task definition to be executed by the EBX® task scheduler. To define a task, a concrete class extending this abstract class must be implemented. This concrete class must have apublic
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 Constructor Description ScheduledTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
execute(ScheduledExecutionContext aContext)
Executes the current task.void
handleBeforeInterrupting(ScheduledExecutionContext aContext)
When a task interruption has been requested through EBX® administration, this method provides the opportunity to perform actions before actually interrupting the task execution.void
handleBeforePausing(ScheduledExecutionContext aContext)
When a pause has been requested through EBX® administration, this method provides the opportunity to perform actions before entering the pause state.void
handleBeforeResuming(ScheduledExecutionContext aContext)
When the administrator requests to resume a paused schedule task, this method provides the opportunity to perform actions before the task resumes execution.boolean
isInterruptable()
Iftrue
, the current task can be interrupted through EBX® administration.boolean
isPausable()
Iftrue
, the current task can be paused (and resumed) through EBX® administration.void
validate(ValueContextForValidation aValidationContext)
Validates the current task configuration.
-
-
-
Method Detail
-
validate
public void validate(ValueContextForValidation aValidationContext)
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:
OperationException
ScheduledTaskInterruption
- See Also:
ProgrammaticService
-
handleBeforeInterrupting
public void handleBeforeInterrupting(ScheduledExecutionContext aContext) throws OperationException
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.
- Throws:
OperationException
- See Also:
isInterruptable()
,ScheduledExecutionContext.handleExecutionState()
-
handleBeforePausing
public void handleBeforePausing(ScheduledExecutionContext aContext) throws OperationException
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
OperationException
is thrown, the task execution is interrupted.- Throws:
OperationException
- See Also:
isPausable()
,ScheduledExecutionContext.handleExecutionState()
-
handleBeforeResuming
public void handleBeforeResuming(ScheduledExecutionContext aContext) throws OperationException
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
OperationException
is thrown, the task execution is interrupted.Default implementation does nothing. To be overridden if a specific behavior is required.
- Throws:
OperationException
- See Also:
handleBeforePausing(ScheduledExecutionContext)
-
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
.
-
-