Package rife.scheduler
Class Executor
java.lang.Object
rife.scheduler.Executor
- Direct Known Subclasses:
DbKeepAlive
Executor is an abstract class that can be extended to implement the logic
that happen when tasks of a particular type are executing through the
scheduler.
By default, the task type will be determined by the name of the executor class, but it's possible to customize that by overriding the `getHandledTaskType()` method.
- Since:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a new task instance with this executor's task type.abstract booleanexecuteTask(Task task) Needs to be implemented with the logic that should happen when the scheduler executes a task.Returns a string identifying the type of tasks that this executor will handle.protected longProvides the delay in milliseconds that should be used when tasks are being rescheduled after non-successful execution.Retrieves the scheduler that this executor has been registered with.
-
Field Details
-
DEFAULT_RESCHEDULE_DELAY
public static final int DEFAULT_RESCHEDULE_DELAY- See Also:
-
-
Constructor Details
-
Executor
public Executor()
-
-
Method Details
-
executeTask
Needs to be implemented with the logic that should happen when the scheduler executes a task.Sometimes tasks fail to be executed, or the right conditions can't be met. In that case, returning
falsefrom this method will make the scheduler reschedule the same task. The delay that is used for rescheduling is determined by this class'sgetRescheduleDelay()method.- Parameters:
task- the task that needs to be executed.- Returns:
trueif the task successfully executed, orfalseif the task needs to be rescheduled- Since:
- 1.0
- See Also:
-
createTask
Create a new task instance with this executor's task type.- Returns:
- a new task
- Since:
- 1.0
-
getHandledTaskType
Returns a string identifying the type of tasks that this executor will handle.By default, this is the fully qualified class name of this executor, overriding this method allows for other type identifiers to be used.
- Returns:
- this executor's task type
- Since:
- 1.0
-
getRescheduleDelay
protected long getRescheduleDelay()Provides the delay in milliseconds that should be used when tasks are being rescheduled after non-successful execution.By default, this is
1000ms (1 second), overriding this method allows for any other delay to be used.- Returns:
- the delay in milliseconds for task rescheduling
- Since:
- 1.0
-
getScheduler
Retrieves the scheduler that this executor has been registered with.- Returns:
- this executor's scheduler; or
nullif the executor has not been registered with a scheduler yet. - Since:
- 1.0
-