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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate a new task instance with this executor's task type.abstract boolean
executeTask
(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 long
Provides 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
false
from 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:
true
if the task successfully executed, orfalse
if 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
1000
ms (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
null
if the executor has not been registered with a scheduler yet. - Since:
- 1.0
-