Class ScheduledTask
java.lang.Object
ortus.boxlang.runtime.async.tasks.ScheduledTask
- All Implemented Interfaces:
Runnable
The ScheduledTask class is a
Runnable that is used by the schedulers to execute tasks
in a more human and fluent approach.
A task can be represented either by a DynamicObject or a Java Callable Lambda.
You can use this class to create scheduled tasks in a human and friendly way!-
Constructor Summary
ConstructorsConstructorDescriptionScheduledTask(String name, String group, ExecutorRecord executor, BaseScheduler scheduler) Creates a new ScheduledTask with a name and a named group and it's accompanying executorScheduledTask(String name, ExecutorRecord executor) Creates a new ScheduledTask with a name and the default "empty" groupScheduledTask(String name, BaseScheduler scheduler) Creates a new ScheduledTask with a name and the default "empty" group and a scheduler -
Method Summary
Modifier and TypeMethodDescriptionafter(BiConsumer<ScheduledTask, Optional<?>> target) Store the closure to execute after the task is executedbefore(Consumer<ScheduledTask> target) Store the closure to execute before the task is executedSets a daily time range restriction where this task can run on.This method is used to register any executable as a scheduled task.This method is used to register any object that is either: - DynamicObject - IReferenceable - Callable - Runnable as a scheduled task.This method is used to register the Runnable Lambda on this scheduled task.This method is used to register the callable Callable Lambda on this scheduled task.call(DynamicObject task) This method is used to register the callable DynamicObject on this scheduled task.call(DynamicObject task, String method) This method is used to register the callable DynamicObject/Callable lambda on this scheduled task.voidCall this method periodically in a long-running task to check to see if the thread has been interrupted.voidThis method is called ALWAYS after a task runs, wether in failure or success but used internally for any type of cleanupsdelay(long delay) Set an initial delay in the running of the task that will be registered with this schedule in millisecondsSet an initial delay in the running of the task that will be registered with this schedule in millisecondsSet an initial delay in the running of the task that will be registered with this scheduledeleteMetaKey(String key) Delete a meta key/value pair in the meta struct.disable()Disable this task, the human wayenable()Enable this task, the human waySet when this task should stop execution on.Set when this task should stop execution on.Sets a daily end time restriction for this task.every(long period) Run the task every custom period of execution The default time unit is millisecondsRun the task every custom period of executionBoxLang proxyeveryDay()Daily task that runs at midnighteveryDayAt(String time) Run the task daily with a specific time in 24 hour format: HH:mm We will always add 0 seconds for you.Run the task every hour from the time it get's scheduledeveryHourAt(int minutes) Set the period to be hourly at a specific minute mark and 00 secondsRun the task every minute from the time it get's scheduledRun the task on the first day of every month at midnighteveryMonthOn(int day) Run the task every month on a specific day at midnighteveryMonthOn(int day, String time) Run the task every month on a specific day and timeRun the task every second from the time it get's scheduledRun the every Sunday at midnighteveryWeekOn(int dayOfWeek) Run the task weekly on the given day of the week at midnighteveryWeekOn(int dayOfWeek, String time) Run the task weekly on the given day of the week and timeRun the task on the first day of the year at midnighteveryYearOn(int month, int day) Set the period to be weekly at a specific time at a specific day of the weekeveryYearOn(int month, int day, String time) Set the period to be weekly at a specific time at a specific day of the weekGet the after task lambda.Get the before task lambda.intGet the constraint of what day of the month we need to run on: 1-31.intGet the constraint of what day of the week this runs on: 1-7.Get the constraint of when the task must not continue to execute.Get the constraint to limit the task to run before a specified time of day.getGroup()Get the human group name of this task.longGet the delay or time to wait before we execute the task in the scheduler.Get the time unit string used when there is a delay requested for the task.Get the constraint to run only on the last business day of the month.Optional<?> Get the last result of the taskgetMeta()Get the Meta struct for the task that can be used to store any metadata.Get the method to execute in the DynamicObject, by default it is run().getName()Get the human name of this task.Get the NoOverlaps flaggetNow()Get the date time now in the timezone of the taskGet the task failure lambda.Get the task success lambda.longGet a fixed time period of execution of the tasks in this schedule.Get the bound scheduler for this task or null if none.longGet the delay to use when using scheduleWithFixedDelay(), so tasks execute after this delay once completed.Get the constraint of when the task can start execution.Get the constraint to limit the task to run after a specified time of day.getStats()Get the task statsgetTask()Get the task dynamic object that will be executed by the task.Get the time of day for use in setNextRunTime().Get the time unit used to schedule the task.Get the timezone this task runs under.Get the constraint to run only on weekdays.Get the constraint to run only on weekends.Get a lambda that determines if this task will be sent for scheduling or not.Check if this task has a scheduler bound to it.inDays()Set the time unit in daysinHours()Set the time unit in hoursSet the time unit in microsecondsSet the time unit in millisecondsSet the time unit in minutesSet the time unit in nanosecondsSet the time unit in secondsGet a handy boolean that is set when the task is annually scheduled.booleanThis method verifies if the running task is constrained to run on specific valid constraints: - when - dayOfTheMonth - dayOfTheWeek - firstBusinessDay - lastBusinessDay - weekdays - weekends - startOnDateTime - endOnDateTime - startTime and/or endTime This method is called by the `run()` method at runtime to determine if the task can be ran at that point in timeIs the task disabledIs the task enabledGet a boolean flag that turns off task stacking.Get a boolean value that lets us know if this task has been scheduled.onFailure(BiConsumer<ScheduledTask, Exception> target) Store the closure to execute after the task is executed successfullyRun the task on the first Monday of every month at midnightRun the task on the first Monday of every monthSet the period to be on FridaysSet the period to be on FridaysRun the task on the last business day of the month at midnightRun the task on the last business day of the monthSet the period to be on MondaysSet the period to be on MondaysSet the period to be on SaturdaysonSaturdays(String time) Set the period to be on SaturdaysonSuccess(BiConsumer<ScheduledTask, Optional<?>> target) Store the closure to execute after the task is executed successfullySet the period to be on SundaysSet the period to be on SundaysSet the period to be on ThursdaysonThursdays(String time) Set the period to be on ThursdaysSet the period to be on TuesdaysonTuesdays(String time) Set the period to be on TuesdaysSet the period to be on WednesdaysonWednesdays(String time) Set the period to be on WednesdaysSet the period to be from Monday - Friday at midnightonWeekdays(String time) Set the period to be from Monday - FridayRun the task on saturday and sundays at midnightonWeekends(String time) Run the task on saturday and sundaysvoidrun()This is the runnable proxy method that executes your code by the executorsvoidThis is a convenience method to execute the task manually if needed by forcing execution.setAfterTask(BiConsumer<ScheduledTask, Optional<?>> afterTask) Set the after task lambda.setAnnually(Boolean annually) Set a handy boolean that is set when the task is annually scheduled.setBeforeTask(Consumer<ScheduledTask> beforeTask) Set the before task lambda.setDayOfTheMonth(int dayOfTheMonth) Set the constraint of what day of the month we need to run on: 1-31.setDayOfTheWeek(int dayOfTheWeek) Set the constraint of what day of the week this runs on: 1-7.setDisabled(Boolean disabled) Set a handy boolean that disables the scheduling of this task.setEndOnDateTime(LocalDateTime endOnDateTime) Set the constraint of when the task must not continue to execute.setEndTime(String endTime) Set the constraint to limit the task to run before a specified time of day.setFirstBusinessDay(Boolean firstBusinessDay) Set the constraint to run only on the first business day of the month.Set the human group name of this task.setInitialDelay(long delay) Set the delay or time to wait before we execute the task in the scheduler.setInitialDelayTimeUnit(TimeUnit delayTimeUnit) Set the time unit string used when there is a delay requested for the task.setLastBusinessDay(Boolean lastBusinessDay) Set the constraint to run only on the last business day of the month.Set the Meta struct for the task that can be used to store any metadata.setMetaKey(String key, Object value) Set a meta key/value pair in the meta struct.Set the method to execute in the DynamicObject, by default it is run().Set the human name of this task.setNoOverlaps(Boolean noOverlaps) Set a boolean flag that turns off task stacking.setOnTaskFailure(BiConsumer<ScheduledTask, Exception> onTaskFailure) Set the task failure lambda.setOnTaskSuccess(BiConsumer<ScheduledTask, Optional<?>> onTaskSuccess) Set the task success lambda.setPeriod(long period) Set a fixed time period of execution of the tasks in this schedule.setScheduled(Boolean scheduled) Set a boolean value that lets us know if this task has been scheduled.setScheduler(BaseScheduler scheduler) Set the bound scheduler for this task.setSpacedDelay(long spacedDelay) Set the delay to use when using scheduleWithFixedDelay(), so tasks execute after this delay once completed.setStartOnDateTime(LocalDateTime startOnDateTime) Set the constraint of when the task can start execution.setStartTime(String startTime) Set the constraint to limit the task to run after a specified time of day.Set the task dynamic object that will be executed by the task.setTaskTime(String taskTime) Set the time of day for use in setNextRunTime().setTimeUnit(TimeUnit timeUnit) Set the time unit used to schedule the task.setTimezone(String timezone) Set the timezone this task runs under using a timezone string representationsetTimezone(ZoneId timezone) Set the timezone this task runs under.setWeekdays(Boolean weekdays) Set the constraint to run only on weekdays.setWeekends(Boolean weekends) Set the constraint to run only on weekends.setWhenPredicate(Predicate<ScheduledTask> whenPredicate) Set a lambda that determines if this task will be sent for scheduling or not.spacedDelay(long spacedDelay) spacedDelay(long spacedDelay, TimeUnit timeUnit) Run the task every custom spaced delay of execution, meaning no overlapsstart()This method registers the task into the executor and sends it for execution and scheduling.Set when this task should start execution on.Set when this task should start execution on.startOnTime(String time) Sets a daily start time restriction for this task.when(Predicate<ScheduledTask> target) Register a when lambda that will be executed to verify if the task can run.Calling this method prevents task frequencies to overlap.
-
Constructor Details
-
ScheduledTask
Creates a new ScheduledTask with a name and a named group and it's accompanying executor- Parameters:
name- The name of the taskgroup- The group of the taskexecutor- The executor we are bound toscheduler- The scheduler we are bound to
-
ScheduledTask
Creates a new ScheduledTask with a name and the default "empty" group- Parameters:
name- The name of the taskexecutor- The executor we are bound to
-
ScheduledTask
Creates a new ScheduledTask with a name and the default "empty" group and a scheduler- Parameters:
name- The name of the taskscheduler- The scheduler we are bound to
-
-
Method Details
-
run
public void run()This is the runnable proxy method that executes your code by the executors -
run
This is a convenience method to execute the task manually if needed by forcing execution.- Parameters:
force- Whether to force execution or not. It ignores if the task is disabled or constrained
-
getLastResult
Get the last result of the task- Returns:
- The last result of the task as an Optional
-
start
This method registers the task into the executor and sends it for execution and scheduling. This will not register the task for execution if the disabled flag or the constraints allow it.- Returns:
- A ScheduledFuture from where you can monitor the task, an empty ScheduledFuture if the task was not registered
-
before
Store the closure to execute before the task is executed- Parameters:
target- The closure to execute
-
after
Store the closure to execute after the task is executed- Parameters:
target- The closure to execute
-
onSuccess
Store the closure to execute after the task is executed successfully- Parameters:
target- The closure to execute
-
onFailure
Store the closure to execute after the task is executed successfully- Parameters:
target- The closure to execute
-
call
This method is used to register the callable DynamicObject on this scheduled task.- Parameters:
task- The DynamicObject to register with a run() method- Returns:
- The ScheduledTask instance
-
call
This method is used to register the callable DynamicObject/Callable lambda on this scheduled task.- Parameters:
task- The DynamicObject/Functional Lambda to registermethod- The method to execute in the DynamicObject/Functional Lambda, by default it is run()- Returns:
- The ScheduledTask instance
-
call
This method is used to register the callable Callable Lambda on this scheduled task.- Parameters:
task- The Callable Lambda to register- Returns:
- The ScheduledTask instance
-
call
This method is used to register the Runnable Lambda on this scheduled task.- Parameters:
task- TheRunnableLambda to register- Returns:
- The ScheduledTask instance
-
call
This method is used to register any executable as a scheduled task.- Parameters:
task- The object to register as an executable task- Returns:
- The ScheduledTask instance
-
call
This method is used to register any object that is either: - DynamicObject - IReferenceable - Callable - Runnable as a scheduled task.- Parameters:
task- The object to register as an executable taskmethod- The method to execute in the object, by default it is run()- Returns:
- The ScheduledTask instance
-
isConstrained
public boolean isConstrained()This method verifies if the running task is constrained to run on specific valid constraints: - when - dayOfTheMonth - dayOfTheWeek - firstBusinessDay - lastBusinessDay - weekdays - weekends - startOnDateTime - endOnDateTime - startTime and/or endTime This method is called by the `run()` method at runtime to determine if the task can be ran at that point in time -
when
Register a when lambda that will be executed to verify if the task can run. If the lambda returns true we execute it, else we don't.- Parameters:
target- The lambda to execute
-
startOn
Set when this task should start execution on. By default it starts automatically.- Parameters:
date- The date when this task should start execution on => yyyy-mm-dd format is preferred.time- The specific time using 24 hour format => HH:mm, defaults to 00:00
-
startOn
Set when this task should start execution on. By default it starts automatically.- Parameters:
date- The date when this task should start execution on => yyyy-mm-dd format is preferred.
-
startOnTime
Sets a daily start time restriction for this task.- Parameters:
time- The specific time using 24 hour format => HH:mm- Throws:
InvalidAttributeValueException
-
endOn
Set when this task should stop execution on. By default it never ends.- Parameters:
date- The date when this task should stop execution on => yyyy-mm-dd format is preferred.time- The specific time using 24 hour format => HH:mm, defaults to 00:00
-
endOn
Set when this task should stop execution on. By default it never ends.- Parameters:
date- The date when this task should stop execution on => yyyy-mm-dd format is preferred.
-
endOnTime
Sets a daily end time restriction for this task.- Parameters:
time- The specific time using 24 hour format => HH:mm- Throws:
InvalidAttributeValueException
-
between
public ScheduledTask between(String startTime, String endTime) throws InvalidAttributeValueException Sets a daily time range restriction where this task can run on.- Parameters:
startTime- The specific time using 24 hour format => HH:mmendTime- The specific time using 24 hour format => HH:mm- Throws:
InvalidAttributeValueException- When the time format is invalid
-
delay
Set an initial delay in the running of the task that will be registered with this schedule- Parameters:
delay- The delay that will be used before executing the tasktimeUnit- The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default is millisecondsoverwrites- Boolean to overwrite delay and delayTimeUnit even if value is already set, this is helpful if the delay is set later in the chain when creating the task - defaults to false
-
delay
Set an initial delay in the running of the task that will be registered with this schedule in milliseconds- Parameters:
delay- The delay that will be used before executing the tasktimeunit- The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default- Returns:
- The ScheduledTask instance
-
delay
Set an initial delay in the running of the task that will be registered with this schedule in milliseconds- Parameters:
delay- The delay that will be used before executing the task- Returns:
- The ScheduledTask instance
-
spacedDelay
Run the task every custom spaced delay of execution, meaning no overlaps- Parameters:
spacedDelay- The delay that will be used before executing the task with no overlapstimeUnit- The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default is milliseconds
-
spacedDelay
-
withNoOverlaps
Calling this method prevents task frequencies to overlap. By default all tasks are executed with an interval but could potentially overlap if they take longer to execute than the period. -
every
BoxLang proxy- Parameters:
period- The period of executiontimeunit- The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default- Returns:
- The ScheduledTask instance
-
every
Run the task every custom period of execution- Parameters:
period- The period of executiontimeUnit- The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default is milliseconds
-
every
Run the task every custom period of execution The default time unit is milliseconds- Parameters:
period- The period of execution
-
everySecond
Run the task every second from the time it get's scheduled -
everyMinute
Run the task every minute from the time it get's scheduled -
everyHour
Run the task every hour from the time it get's scheduled -
everyHourAt
Set the period to be hourly at a specific minute mark and 00 seconds- Parameters:
minutes- The minutes past the hour mark
-
everyDay
Daily task that runs at midnight- Returns:
- The ScheduledTask instance
- Throws:
InvalidAttributeValueException
-
everyDayAt
Run the task daily with a specific time in 24 hour format: HH:mm We will always add 0 seconds for you.- Parameters:
time- The specific time using 24 hour format => HH:mm- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyWeek
Run the every Sunday at midnight- Returns:
- The ScheduledTask instance
- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyWeekOn
Run the task weekly on the given day of the week at midnight- Parameters:
dayOfWeek- The day of the week from 1 (Monday) -> 7 (Sunday)- Returns:
- The ScheduledTask instance
- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyWeekOn
Run the task weekly on the given day of the week and time- Parameters:
dayOfWeek- The day of the week from 1 (Monday) -> 7 (Sunday)time- The specific time using 24 hour format => HH:mm, defaults to midnight- Returns:
- The ScheduledTask instance
- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyMonth
Run the task on the first day of every month at midnight- Returns:
- The ScheduledTask instance
- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyMonthOn
Run the task every month on a specific day at midnight- Parameters:
day- Which day of the month- Returns:
- The ScheduledTask instance
- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyMonthOn
Run the task every month on a specific day and time- Parameters:
day- Which day of the monthtime- The specific time using 24 hour format => HH:mm, defaults to midnight- Returns:
- The ScheduledTask instance
- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onFirstBusinessDayOfTheMonth
Run the task on the first Monday of every month at midnight- Throws:
InvalidAttributeValueException
-
onFirstBusinessDayOfTheMonth
public ScheduledTask onFirstBusinessDayOfTheMonth(String time) throws InvalidAttributeValueException Run the task on the first Monday of every month- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to midnight- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onLastBusinessDayOfTheMonth
Run the task on the last business day of the month at midnight- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onLastBusinessDayOfTheMonth
Run the task on the last business day of the month- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to midnight- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyYear
Run the task on the first day of the year at midnight- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyYearOn
Set the period to be weekly at a specific time at a specific day of the week- Parameters:
month- The month in numeric format 1-12day- Which day of the month- Throws:
InvalidAttributeValueException- When the time format is invalid
-
everyYearOn
public ScheduledTask everyYearOn(int month, int day, String time) throws InvalidAttributeValueException Set the period to be weekly at a specific time at a specific day of the week- Parameters:
month- The month in numeric format 1-12day- Which day of the monthtime- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onWeekends
Run the task on saturday and sundays at midnight- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onWeekends
Run the task on saturday and sundays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onWeekdays
Set the period to be from Monday - Friday at midnight- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onWeekdays
Set the period to be from Monday - Friday- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException- When the time format is invalid
-
onMondays
Set the period to be on Mondays- Throws:
InvalidAttributeValueException
-
onMondays
Set the period to be on Mondays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException
-
onTuesdays
Set the period to be on Tuesdays- Throws:
InvalidAttributeValueException
-
onTuesdays
Set the period to be on Tuesdays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException
-
onWednesdays
Set the period to be on Wednesdays- Throws:
InvalidAttributeValueException
-
onWednesdays
Set the period to be on Wednesdays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException
-
onThursdays
Set the period to be on Thursdays- Throws:
InvalidAttributeValueException
-
onThursdays
Set the period to be on Thursdays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException
-
onFridays
Set the period to be on Fridays- Throws:
InvalidAttributeValueException
-
onFridays
Set the period to be on Fridays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException
-
onSaturdays
Set the period to be on Saturdays- Throws:
InvalidAttributeValueException
-
onSaturdays
Set the period to be on Saturdays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException
-
onSundays
Set the period to be on Sundays- Throws:
InvalidAttributeValueException
-
onSundays
Set the period to be on Sundays- Parameters:
time- The specific time using 24 hour format => HH:mm, defaults to 00:00- Throws:
InvalidAttributeValueException
-
inDays
Set the time unit in days -
inHours
Set the time unit in hours -
inMicroseconds
Set the time unit in microseconds -
inMilliseconds
Set the time unit in milliseconds -
inMinutes
Set the time unit in minutes -
inNanoseconds
Set the time unit in nanoseconds -
inSeconds
Set the time unit in seconds -
cleanupTaskRun
public void cleanupTaskRun()This method is called ALWAYS after a task runs, wether in failure or success but used internally for any type of cleanups -
getNow
Get the date time now in the timezone of the task- Returns:
- The date time now in the timezone of the task
-
checkInterrupted
Call this method periodically in a long-running task to check to see if the thread has been interrupted.- Throws:
InterruptedException- - When the thread has been interrupted
-
getName
Get the human name of this task. -
setName
Set the human name of this task. -
setGroup
Set the human group name of this task.- Parameters:
group- the group to set
-
getGroup
Get the human group name of this task.- Returns:
- the group
-
getTask
Get the task dynamic object that will be executed by the task. Must implement the run() method or use themethodproperty. -
setTask
Set the task dynamic object that will be executed by the task. Must implement the run() method or use themethodproperty.- Parameters:
task- the task to set- Returns:
- The ScheduledTask instance
- Throws:
IllegalArgumentException- When the task is not a DynamicObject or a Callable Lambda
-
getMethod
Get the method to execute in the DynamicObject, by default it is run(). -
setMethod
Set the method to execute in the DynamicObject, by default it is run(). -
getStats
Get the task stats- Returns:
- the stats
-
getInitialDelay
public long getInitialDelay()Get the delay or time to wait before we execute the task in the scheduler. -
setInitialDelay
Set the delay or time to wait before we execute the task in the scheduler. -
getInitialDelayTimeUnit
Get the time unit string used when there is a delay requested for the task. -
setInitialDelayTimeUnit
Set the time unit string used when there is a delay requested for the task. -
getPeriod
public long getPeriod()Get a fixed time period of execution of the tasks in this schedule. It does not wait for tasks to finish; tasks are fired exactly at that time period. -
setPeriod
Set a fixed time period of execution of the tasks in this schedule. It does not wait for tasks to finish; tasks are fired exactly at that time period. -
getSpacedDelay
public long getSpacedDelay()Get the delay to use when using scheduleWithFixedDelay(), so tasks execute after this delay once completed. -
setSpacedDelay
Set the delay to use when using scheduleWithFixedDelay(), so tasks execute after this delay once completed. -
getTimeUnit
Get the time unit used to schedule the task. -
setTimeUnit
Set the time unit used to schedule the task. -
isAnnually
Get a handy boolean that is set when the task is annually scheduled. -
setAnnually
Set a handy boolean that is set when the task is annually scheduled. -
isDisabled
Is the task disabled -
isEnabled
Is the task enabled -
setDisabled
Set a handy boolean that disables the scheduling of this task.- Parameters:
disabled- The disabled to set
-
disable
Disable this task, the human way- Returns:
- The ScheduledTask instance
-
enable
Enable this task, the human way- Returns:
- The ScheduledTask instance
-
getWhenPredicate
Get a lambda that determines if this task will be sent for scheduling or not. It is both evaluated at scheduling and at runtime. -
setWhenPredicate
Set a lambda that determines if this task will be sent for scheduling or not. It is both evaluated at scheduling and at runtime. -
getDayOfTheMonth
public int getDayOfTheMonth()Get the constraint of what day of the month we need to run on: 1-31. -
setDayOfTheMonth
Set the constraint of what day of the month we need to run on: 1-31. -
getDayOfTheWeek
public int getDayOfTheWeek()Get the constraint of what day of the week this runs on: 1-7. -
setDayOfTheWeek
Set the constraint of what day of the week this runs on: 1-7. -
getWeekends
Get the constraint to run only on weekends. -
setWeekends
Set the constraint to run only on weekends. -
getWeekdays
Get the constraint to run only on weekdays. -
setWeekdays
Set the constraint to run only on weekdays. -
getFirstBusinessDay
- Returns:
- the firstBusinessDay
-
setFirstBusinessDay
Set the constraint to run only on the first business day of the month. -
getLastBusinessDay
Get the constraint to run only on the last business day of the month. -
setLastBusinessDay
Set the constraint to run only on the last business day of the month. -
isNoOverlaps
Get a boolean flag that turns off task stacking. By default, tasks execute in an interval frequency which can cause tasks to stack if they take longer than their periods (fire immediately after completion). With this flag turned on, the schedulers don't kick off the intervals until the tasks finish executing, meaning no stacking. -
getNoOverlaps
Get the NoOverlaps flag- Returns:
- the noOverlaps
-
setNoOverlaps
Set a boolean flag that turns off task stacking. By default, tasks execute in an interval frequency which can cause tasks to stack if they take longer than their periods (fire immediately after completion). With this flag turned on, the schedulers don't kick off the intervals until the tasks finish executing, meaning no stacking. -
getTaskTime
Get the time of day for use in setNextRunTime(). -
setTaskTime
Set the time of day for use in setNextRunTime(). -
getStartOnDateTime
Get the constraint of when the task can start execution. -
setStartOnDateTime
Set the constraint of when the task can start execution. -
getEndOnDateTime
Get the constraint of when the task must not continue to execute. -
setEndOnDateTime
Set the constraint of when the task must not continue to execute. -
getStartTime
Get the constraint to limit the task to run after a specified time of day. -
setStartTime
Set the constraint to limit the task to run after a specified time of day. -
getEndTime
Get the constraint to limit the task to run before a specified time of day. -
setEndTime
Set the constraint to limit the task to run before a specified time of day. -
isScheduled
Get a boolean value that lets us know if this task has been scheduled. -
setScheduled
Set a boolean value that lets us know if this task has been scheduled. -
getMeta
Get the Meta struct for the task that can be used to store any metadata.- Returns:
- the meta
-
setMeta
Set the Meta struct for the task that can be used to store any metadata.- Parameters:
meta- the meta to set
-
setMetaKey
Set a meta key/value pair in the meta struct.- Parameters:
key- The key to setvalue- The value to set- Returns:
- The ScheduledTask instance
-
deleteMetaKey
Delete a meta key/value pair in the meta struct.- Parameters:
key- The key to delete- Returns:
- The ScheduledTask instance
-
getTimezone
Get the timezone this task runs under. By default, we use the timezone defined in the schedulers. -
setTimezone
Set the timezone this task runs under. By default, we use the timezone defined in the schedulers.- Parameters:
timezone- The timezone to set as a ZoneId
-
setTimezone
Set the timezone this task runs under using a timezone string representation- Parameters:
timezone- The timezone to set as a string
-
getScheduler
Get the bound scheduler for this task or null if none.- Returns:
- the scheduler or null if not bound
-
hasScheduler
Check if this task has a scheduler bound to it.- Returns:
- true if it has a scheduler, false otherwise
-
setScheduler
Set the bound scheduler for this task.- Parameters:
scheduler- the scheduler to set
-
getBeforeTask
Get the before task lambda. -
setBeforeTask
Set the before task lambda. -
getAfterTask
Get the after task lambda. -
setAfterTask
Set the after task lambda. -
getOnTaskSuccess
Get the task success lambda. -
setOnTaskSuccess
Set the task success lambda. -
getOnTaskFailure
Get the task failure lambda. -
setOnTaskFailure
Set the task failure lambda.
-