Class ScheduledTask

java.lang.Object
ortus.boxlang.runtime.async.tasks.ScheduledTask
All Implemented Interfaces:
Runnable

public class ScheduledTask extends Object implements 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 Details

    • ScheduledTask

      public ScheduledTask(String name, String group, ExecutorRecord executor, BaseScheduler scheduler)
      Creates a new ScheduledTask with a name and a named group and it's accompanying executor
      Parameters:
      name - The name of the task
      group - The group of the task
      executor - The executor we are bound to
      scheduler - The scheduler we are bound to
    • ScheduledTask

      public ScheduledTask(String name, ExecutorRecord executor)
      Creates a new ScheduledTask with a name and the default "empty" group
      Parameters:
      name - The name of the task
      executor - The executor we are bound to
    • ScheduledTask

      public ScheduledTask(String name, BaseScheduler scheduler)
      Creates a new ScheduledTask with a name and the default "empty" group and a scheduler
      Parameters:
      name - The name of the task
      scheduler - 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
      Specified by:
      run in interface Runnable
    • run

      public void run(Boolean force)
      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

      public Optional<?> getLastResult()
      Get the last result of the task
      Returns:
      The last result of the task as an Optional
    • start

      public ScheduledFuture<?> 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

      public ScheduledTask before(Consumer<ScheduledTask> target)
      Store the closure to execute before the task is executed
      Parameters:
      target - The closure to execute
    • after

      public ScheduledTask after(BiConsumer<ScheduledTask,Optional<?>> target)
      Store the closure to execute after the task is executed
      Parameters:
      target - The closure to execute
    • onSuccess

      public ScheduledTask onSuccess(BiConsumer<ScheduledTask,Optional<?>> target)
      Store the closure to execute after the task is executed successfully
      Parameters:
      target - The closure to execute
    • onFailure

      public ScheduledTask onFailure(BiConsumer<ScheduledTask,Exception> target)
      Store the closure to execute after the task is executed successfully
      Parameters:
      target - The closure to execute
    • call

      public ScheduledTask call(DynamicObject task)
      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

      public ScheduledTask call(DynamicObject task, String method)
      This method is used to register the callable DynamicObject/Callable lambda on this scheduled task.
      Parameters:
      task - The DynamicObject/Functional Lambda to register
      method - The method to execute in the DynamicObject/Functional Lambda, by default it is run()
      Returns:
      The ScheduledTask instance
    • call

      public ScheduledTask call(Callable<?> task)
      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

      public ScheduledTask call(Runnable task)
      This method is used to register the Runnable Lambda on this scheduled task.
      Parameters:
      task - The Runnable Lambda to register
      Returns:
      The ScheduledTask instance
    • call

      public ScheduledTask call(Object task)
      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

      public ScheduledTask call(Object task, String method)
      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 task
      method - 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

      public ScheduledTask when(Predicate<ScheduledTask> target)
      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

      public ScheduledTask startOn(String date, String time)
      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

      public ScheduledTask startOn(String date)
      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

      public ScheduledTask startOnTime(String time) throws InvalidAttributeValueException
      Sets a daily start time restriction for this task.
      Parameters:
      time - The specific time using 24 hour format => HH:mm
      Throws:
      InvalidAttributeValueException
    • endOn

      public ScheduledTask endOn(String date, String time)
      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

      public ScheduledTask endOn(String date)
      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

      public ScheduledTask endOnTime(String time) throws InvalidAttributeValueException
      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:mm
      endTime - The specific time using 24 hour format => HH:mm
      Throws:
      InvalidAttributeValueException - When the time format is invalid
    • delay

      public ScheduledTask delay(long delay, TimeUnit timeUnit, Boolean overwrites)
      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 task
      timeUnit - The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default is milliseconds
      overwrites - 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

      public ScheduledTask delay(long delay, TimeUnit timeunit)
      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
      timeunit - The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default
      Returns:
      The ScheduledTask instance
    • delay

      public ScheduledTask delay(long 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

      public ScheduledTask spacedDelay(long spacedDelay, TimeUnit timeUnit)
      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 overlaps
      timeUnit - The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default is milliseconds
    • spacedDelay

      public ScheduledTask spacedDelay(long spacedDelay)
    • withNoOverlaps

      public ScheduledTask 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

      public ScheduledTask every(Double period, String timeUnit)
      BoxLang proxy
      Parameters:
      period - The period of execution
      timeunit - The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default
      Returns:
      The ScheduledTask instance
    • every

      public ScheduledTask every(long period, TimeUnit timeUnit)
      Run the task every custom period of execution
      Parameters:
      period - The period of execution
      timeUnit - The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default is milliseconds
    • every

      public ScheduledTask every(long period)
      Run the task every custom period of execution The default time unit is milliseconds
      Parameters:
      period - The period of execution
    • everySecond

      public ScheduledTask everySecond()
      Run the task every second from the time it get's scheduled
    • everyMinute

      public ScheduledTask everyMinute()
      Run the task every minute from the time it get's scheduled
    • everyHour

      public ScheduledTask everyHour()
      Run the task every hour from the time it get's scheduled
    • everyHourAt

      public ScheduledTask everyHourAt(int minutes)
      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

      public ScheduledTask everyDayAt(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask everyWeek() throws InvalidAttributeValueException
      Run the every Sunday at midnight
      Returns:
      The ScheduledTask instance
      Throws:
      InvalidAttributeValueException - When the time format is invalid
    • everyWeekOn

      public ScheduledTask everyWeekOn(int dayOfWeek) throws InvalidAttributeValueException
      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

      public ScheduledTask everyWeekOn(int dayOfWeek, String time) throws InvalidAttributeValueException
      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

      public ScheduledTask everyMonth() throws InvalidAttributeValueException
      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

      public ScheduledTask everyMonthOn(int day) throws InvalidAttributeValueException
      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

      public ScheduledTask everyMonthOn(int day, String time) throws InvalidAttributeValueException
      Run the task every month on a specific day and time
      Parameters:
      day - Which day of the month
      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
    • onFirstBusinessDayOfTheMonth

      public ScheduledTask onFirstBusinessDayOfTheMonth() throws InvalidAttributeValueException
      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

      public ScheduledTask onLastBusinessDayOfTheMonth() throws InvalidAttributeValueException
      Run the task on the last business day of the month at midnight
      Throws:
      InvalidAttributeValueException - When the time format is invalid
    • onLastBusinessDayOfTheMonth

      public ScheduledTask onLastBusinessDayOfTheMonth(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask everyYear() throws InvalidAttributeValueException
      Run the task on the first day of the year at midnight
      Throws:
      InvalidAttributeValueException - When the time format is invalid
    • everyYearOn

      public ScheduledTask everyYearOn(int month, int day) 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-12
      day - 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-12
      day - Which day of the month
      time - The specific time using 24 hour format => HH:mm, defaults to 00:00
      Throws:
      InvalidAttributeValueException - When the time format is invalid
    • onWeekends

      public ScheduledTask onWeekends() throws InvalidAttributeValueException
      Run the task on saturday and sundays at midnight
      Throws:
      InvalidAttributeValueException - When the time format is invalid
    • onWeekends

      public ScheduledTask onWeekends(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onWeekdays() throws InvalidAttributeValueException
      Set the period to be from Monday - Friday at midnight
      Throws:
      InvalidAttributeValueException - When the time format is invalid
    • onWeekdays

      public ScheduledTask onWeekdays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onMondays() throws InvalidAttributeValueException
      Set the period to be on Mondays
      Throws:
      InvalidAttributeValueException
    • onMondays

      public ScheduledTask onMondays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onTuesdays() throws InvalidAttributeValueException
      Set the period to be on Tuesdays
      Throws:
      InvalidAttributeValueException
    • onTuesdays

      public ScheduledTask onTuesdays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onWednesdays() throws InvalidAttributeValueException
      Set the period to be on Wednesdays
      Throws:
      InvalidAttributeValueException
    • onWednesdays

      public ScheduledTask onWednesdays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onThursdays() throws InvalidAttributeValueException
      Set the period to be on Thursdays
      Throws:
      InvalidAttributeValueException
    • onThursdays

      public ScheduledTask onThursdays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onFridays() throws InvalidAttributeValueException
      Set the period to be on Fridays
      Throws:
      InvalidAttributeValueException
    • onFridays

      public ScheduledTask onFridays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onSaturdays() throws InvalidAttributeValueException
      Set the period to be on Saturdays
      Throws:
      InvalidAttributeValueException
    • onSaturdays

      public ScheduledTask onSaturdays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask onSundays() throws InvalidAttributeValueException
      Set the period to be on Sundays
      Throws:
      InvalidAttributeValueException
    • onSundays

      public ScheduledTask onSundays(String time) throws InvalidAttributeValueException
      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

      public ScheduledTask inDays()
      Set the time unit in days
    • inHours

      public ScheduledTask inHours()
      Set the time unit in hours
    • inMicroseconds

      public ScheduledTask inMicroseconds()
      Set the time unit in microseconds
    • inMilliseconds

      public ScheduledTask inMilliseconds()
      Set the time unit in milliseconds
    • inMinutes

      public ScheduledTask inMinutes()
      Set the time unit in minutes
    • inNanoseconds

      public ScheduledTask inNanoseconds()
      Set the time unit in nanoseconds
    • inSeconds

      public ScheduledTask 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

      public LocalDateTime getNow()
      Get the date time now in the timezone of the task
      Returns:
      The date time now in the timezone of the task
    • checkInterrupted

      public void checkInterrupted() throws InterruptedException
      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

      public String getName()
      Get the human name of this task.
    • setName

      public ScheduledTask setName(String name)
      Set the human name of this task.
    • setGroup

      public ScheduledTask setGroup(String group)
      Set the human group name of this task.
      Parameters:
      group - the group to set
    • getGroup

      public String getGroup()
      Get the human group name of this task.
      Returns:
      the group
    • getTask

      public Object getTask()
      Get the task dynamic object that will be executed by the task. Must implement the run() method or use the method property.
    • setTask

      public ScheduledTask setTask(Object task)
      Set the task dynamic object that will be executed by the task. Must implement the run() method or use the method property.
      Parameters:
      task - the task to set
      Returns:
      The ScheduledTask instance
      Throws:
      IllegalArgumentException - When the task is not a DynamicObject or a Callable Lambda
    • getMethod

      public String getMethod()
      Get the method to execute in the DynamicObject, by default it is run().
    • setMethod

      public ScheduledTask setMethod(String method)
      Set the method to execute in the DynamicObject, by default it is run().
    • getStats

      public IStruct 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

      public ScheduledTask setInitialDelay(long delay)
      Set the delay or time to wait before we execute the task in the scheduler.
    • getInitialDelayTimeUnit

      public TimeUnit getInitialDelayTimeUnit()
      Get the time unit string used when there is a delay requested for the task.
    • setInitialDelayTimeUnit

      public ScheduledTask setInitialDelayTimeUnit(TimeUnit delayTimeUnit)
      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

      public ScheduledTask setPeriod(long period)
      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

      public ScheduledTask setSpacedDelay(long spacedDelay)
      Set the delay to use when using scheduleWithFixedDelay(), so tasks execute after this delay once completed.
    • getTimeUnit

      public TimeUnit getTimeUnit()
      Get the time unit used to schedule the task.
    • setTimeUnit

      public ScheduledTask setTimeUnit(TimeUnit timeUnit)
      Set the time unit used to schedule the task.
    • isAnnually

      public Boolean isAnnually()
      Get a handy boolean that is set when the task is annually scheduled.
    • setAnnually

      public ScheduledTask setAnnually(Boolean annually)
      Set a handy boolean that is set when the task is annually scheduled.
    • isDisabled

      public Boolean isDisabled()
      Is the task disabled
    • isEnabled

      public Boolean isEnabled()
      Is the task enabled
    • setDisabled

      public ScheduledTask setDisabled(Boolean disabled)
      Set a handy boolean that disables the scheduling of this task.
      Parameters:
      disabled - The disabled to set
    • disable

      public ScheduledTask disable()
      Disable this task, the human way
      Returns:
      The ScheduledTask instance
    • enable

      public ScheduledTask enable()
      Enable this task, the human way
      Returns:
      The ScheduledTask instance
    • getWhenPredicate

      public Predicate<ScheduledTask> 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

      public ScheduledTask setWhenPredicate(Predicate<ScheduledTask> whenPredicate)
      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

      public ScheduledTask setDayOfTheMonth(int dayOfTheMonth)
      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

      public ScheduledTask setDayOfTheWeek(int dayOfTheWeek)
      Set the constraint of what day of the week this runs on: 1-7.
    • getWeekends

      public Boolean getWeekends()
      Get the constraint to run only on weekends.
    • setWeekends

      public ScheduledTask setWeekends(Boolean weekends)
      Set the constraint to run only on weekends.
    • getWeekdays

      public Boolean getWeekdays()
      Get the constraint to run only on weekdays.
    • setWeekdays

      public ScheduledTask setWeekdays(Boolean weekdays)
      Set the constraint to run only on weekdays.
    • getFirstBusinessDay

      public Boolean getFirstBusinessDay()
      Returns:
      the firstBusinessDay
    • setFirstBusinessDay

      public ScheduledTask setFirstBusinessDay(Boolean firstBusinessDay)
      Set the constraint to run only on the first business day of the month.
    • getLastBusinessDay

      public Boolean getLastBusinessDay()
      Get the constraint to run only on the last business day of the month.
    • setLastBusinessDay

      public ScheduledTask setLastBusinessDay(Boolean lastBusinessDay)
      Set the constraint to run only on the last business day of the month.
    • isNoOverlaps

      public Boolean 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

      public Boolean getNoOverlaps()
      Get the NoOverlaps flag
      Returns:
      the noOverlaps
    • setNoOverlaps

      public ScheduledTask setNoOverlaps(Boolean noOverlaps)
      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

      public String getTaskTime()
      Get the time of day for use in setNextRunTime().
    • setTaskTime

      public ScheduledTask setTaskTime(String taskTime)
      Set the time of day for use in setNextRunTime().
    • getStartOnDateTime

      public LocalDateTime getStartOnDateTime()
      Get the constraint of when the task can start execution.
    • setStartOnDateTime

      public ScheduledTask setStartOnDateTime(LocalDateTime startOnDateTime)
      Set the constraint of when the task can start execution.
    • getEndOnDateTime

      public LocalDateTime getEndOnDateTime()
      Get the constraint of when the task must not continue to execute.
    • setEndOnDateTime

      public ScheduledTask setEndOnDateTime(LocalDateTime endOnDateTime)
      Set the constraint of when the task must not continue to execute.
    • getStartTime

      public String getStartTime()
      Get the constraint to limit the task to run after a specified time of day.
    • setStartTime

      public ScheduledTask setStartTime(String startTime)
      Set the constraint to limit the task to run after a specified time of day.
    • getEndTime

      public String getEndTime()
      Get the constraint to limit the task to run before a specified time of day.
    • setEndTime

      public ScheduledTask setEndTime(String endTime)
      Set the constraint to limit the task to run before a specified time of day.
    • isScheduled

      public Boolean isScheduled()
      Get a boolean value that lets us know if this task has been scheduled.
    • setScheduled

      public ScheduledTask setScheduled(Boolean scheduled)
      Set a boolean value that lets us know if this task has been scheduled.
    • getMeta

      public IStruct getMeta()
      Get the Meta struct for the task that can be used to store any metadata.
      Returns:
      the meta
    • setMeta

      public ScheduledTask setMeta(IStruct meta)
      Set the Meta struct for the task that can be used to store any metadata.
      Parameters:
      meta - the meta to set
    • setMetaKey

      public ScheduledTask setMetaKey(String key, Object value)
      Set a meta key/value pair in the meta struct.
      Parameters:
      key - The key to set
      value - The value to set
      Returns:
      The ScheduledTask instance
    • deleteMetaKey

      public ScheduledTask deleteMetaKey(String key)
      Delete a meta key/value pair in the meta struct.
      Parameters:
      key - The key to delete
      Returns:
      The ScheduledTask instance
    • getTimezone

      public ZoneId getTimezone()
      Get the timezone this task runs under. By default, we use the timezone defined in the schedulers.
    • setTimezone

      public ScheduledTask setTimezone(ZoneId timezone)
      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

      public ScheduledTask setTimezone(String timezone)
      Set the timezone this task runs under using a timezone string representation
      Parameters:
      timezone - The timezone to set as a string
    • getScheduler

      public BaseScheduler getScheduler()
      Get the bound scheduler for this task or null if none.
      Returns:
      the scheduler or null if not bound
    • hasScheduler

      public Boolean hasScheduler()
      Check if this task has a scheduler bound to it.
      Returns:
      true if it has a scheduler, false otherwise
    • setScheduler

      public ScheduledTask setScheduler(BaseScheduler scheduler)
      Set the bound scheduler for this task.
      Parameters:
      scheduler - the scheduler to set
    • getBeforeTask

      public Consumer<ScheduledTask> getBeforeTask()
      Get the before task lambda.
    • setBeforeTask

      public ScheduledTask setBeforeTask(Consumer<ScheduledTask> beforeTask)
      Set the before task lambda.
    • getAfterTask

      public BiConsumer<ScheduledTask,Optional<?>> getAfterTask()
      Get the after task lambda.
    • setAfterTask

      public ScheduledTask setAfterTask(BiConsumer<ScheduledTask,Optional<?>> afterTask)
      Set the after task lambda.
    • getOnTaskSuccess

      public BiConsumer<ScheduledTask,Optional<?>> getOnTaskSuccess()
      Get the task success lambda.
    • setOnTaskSuccess

      public ScheduledTask setOnTaskSuccess(BiConsumer<ScheduledTask,Optional<?>> onTaskSuccess)
      Set the task success lambda.
    • getOnTaskFailure

      public BiConsumer<ScheduledTask,Exception> getOnTaskFailure()
      Get the task failure lambda.
    • setOnTaskFailure

      public ScheduledTask setOnTaskFailure(BiConsumer<ScheduledTask,Exception> onTaskFailure)
      Set the task failure lambda.