coldbox.system.web.tasks

Class ColdBoxScheduledTask

lucee.Component
    extended by coldbox.system.async.tasks.ScheduledTask
      extended by coldbox.system.web.tasks.ColdBoxScheduledTask

This object represents a scheduled task that will be sent in to a scheduled executor for scheduling. It has a fluent and human dsl for setting it up and restricting is scheduling and frequency of scheduling. A task can be represented as either a closure or a cfc with a `run()` or custom runnable method.

Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any cacheName
          The cache name to use for server fixation and more.

    • access = public
    • returntype = any
    true false
    any cachebox


    • access = public
    • returntype = any
    • inject = cachebox
    true false
    any controller
          --------------------------------------------------------------------------.

    • access = public
    • returntype = any
    • inject = coldbox
    true false
    array environments
          Execution Environment.

    • access = public
    • returntype = any
    true false
    any log


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    boolean serverFixation
          This indicates that the task should ONLY run on one server and not on all servers clustered for the application.

    • access = public
    • returntype = any
    true false
    numeric serverLockTimeout
          How long does the server fixation lock remain for.

    • access = public
    • returntype = any
    true false
    any wirebox


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init(any name, any executor, [any task=''], [any method='run'])
          Constructor.
    Method Summary
    boolean canRunOnThisServer()
         Verifies if a task can run on the executed server by using our distributed cache lock strategy.
    any cleanupTaskRun()
         This method is called ALWAYS after a task runs, wether in failure or success but used internally for.
    coldbox.system.web.tasks.ScheduledTask err(any var)
         Send errors to LogBox.
    any getCache()
         This method retrieves the selected CacheBox provider that will be used for server fixation and much more.
    string getCacheName()
    string getCachebox()
    string getController()
    string getEnvironments()
    string getFixationCacheKey()
         Get the server fixation cache key according to name and scheduler (if any).
    string getLog()
    string getServerFixation()
    string getServerLockTimeout()
    string getWirebox()
    boolean isConstrained()
         This method verifies if the running task is constrained to run on specific valid constraints:.
    ColdBoxScheduledTask onEnvironment(any environment)
         Set the environments that this task can run under ONLY.
    ColdBoxScheduledTask onOneServer()
         This indicates that the task should ONLY run on one server and not on all servers clustered for the application.
    coldbox.system.web.tasks.ScheduledTask out(any var)
         Send info messages to LogBox.
    any setCacheName(any cacheName)
    any setCachebox(any cachebox)
    any setController(any controller)
    any setEnvironments(array environments)
    any setLog(any log)
    any setServerFixation(boolean serverFixation)
    any setServerLockTimeout(numeric serverLockTimeout)
    any setWirebox(any wirebox)
     
    Methods inherited from class coldbox.system.async.tasks.ScheduledTask
    after, before, call, checkInterrupted, delay, disable, enable, endOn, every, everyDay, everyDayAt, everyHour, everyHourAt, everyMinute, everyMonth, everyMonthOn, everyWeek, everyWeekOn, everyYear, everyYearOn, getAfterTask, getBeforeTask, getDayOfTheMonth, getDayOfTheWeek, getDelay, getDisabled, getEndOnDateTime, getJavaNow, getLastBusinessDay, getLastDayOfTheMonth, getMemento, getMethod, getName, getNoOverlaps, getOnTaskFailure, getOnTaskSuccess, getPeriod, getScheduler, getSpacedDelay, getStartOnDateTime, getStats, getTask, getTimeunit, getTimezone, getWeekdays, getWeekends, getWhenClosure, hasScheduler, inDays, inHours, inMicroseconds, inMilliseconds, inMinutes, inNanoseconds, inSeconds, isDisabled, onFailure, onFirstBusinessDayOfTheMonth, onFridays, onLastBusinessDayOfTheMonth, onMondays, onSaturdays, onSuccess, onSundays, onThursdays, onTuesdays, onWednesdays, onWeekdays, onWeekends, run, setAfterTask, setBeforeTask, setDayOfTheMonth, setDayOfTheWeek, setDelay, setDisabled, setEndOnDateTime, setLastBusinessDay, setMethod, setName, setNoOverlaps, setOnTaskFailure, setOnTaskSuccess, setPeriod, setScheduler, setSpacedDelay, setStartOnDateTime, setStats, setTask, setTimeunit, setTimezone, setWeekdays, setWeekends, setWhenClosure, spacedDelay, start, startOn, validateTime, when, withNoOverlaps
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init(any name, any executor, [any task=''], [any method='run'])

    Constructor

    Parameters:
    name - The name of this task
    executor - The executor this task will run under and be linked to
    task - The closure or cfc that represents the task (optional)
    method - The method on the cfc to call, defaults to "run" (optional)

    Property Detail

    cacheName

    property any cacheName

    The cache name to use for server fixation and more. By default we use the template region

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    cachebox

    property any cachebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - cachebox
    serializable - true

    controller

    property any controller

    -------------------------------------------------------------------------- DI --------------------------------------------------------------------------

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox
    serializable - true

    environments

    property array environments

    Execution Environment

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    log

    property any log

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    serverFixation

    property boolean serverFixation

    This indicates that the task should ONLY run on one server and not on all servers clustered for the application. Please note that this will ONLY work if you are using a distributed cache in your application via CacheBox. The default cache region we will use is the template cache, which you can connect to any distributed caching engine like: Redis, Couchbase, Mongo, Elastic, DB etc.

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    serverLockTimeout

    property numeric serverLockTimeout

    How long does the server fixation lock remain for. Deafult is 60 minutes.

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    wirebox

    property any wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    canRunOnThisServer

    public boolean canRunOnThisServer()

    Verifies if a task can run on the executed server by using our distributed cache lock strategy


    cleanupTaskRun

    public any cleanupTaskRun()

    This method is called ALWAYS after a task runs, wether in failure or success but used internally for any type of cleanups

    Overrides:
    cleanupTaskRun in class ScheduledTask

    err

    public coldbox.system.web.tasks.ScheduledTask err(any var)

    Send errors to LogBox

    Overrides:
    err in class ScheduledTask
    Parameters:
    var - Variable/Message to send

    getCache

    public any getCache()

    This method retrieves the selected CacheBox provider that will be used for server fixation and much more.

    Returns:
    coldbox.system.cache.providers.IColdBoxProvider

    getCacheName

    public string getCacheName()


    getCachebox

    public string getCachebox()


    getController

    public string getController()


    getEnvironments

    public string getEnvironments()


    getFixationCacheKey

    public string getFixationCacheKey()

    Get the server fixation cache key according to name and scheduler (if any)


    getLog

    public string getLog()


    getServerFixation

    public string getServerFixation()


    getServerLockTimeout

    public string getServerLockTimeout()


    getWirebox

    public string getWirebox()


    isConstrained

    public boolean isConstrained()

    This method verifies if the running task is constrained to run on specific valid constraints: - when - dayOfTheMonth - dayOfTheWeek - lastBusinessDay - weekends - weekdays - environments - server fixation This method is called by the `run()` method at runtime to determine if the task can be ran at that point in time

    Overrides:
    isConstrained in class ScheduledTask

    onEnvironment

    public ColdBoxScheduledTask onEnvironment(any environment)

    Set the environments that this task can run under ONLY

    Parameters:
    environment - A string, a list, or an array of environments

    onOneServer

    public ColdBoxScheduledTask onOneServer()

    This indicates that the task should ONLY run on one server and not on all servers clustered for the application. Please note that this will ONLY work if you are using a distributed cache in your application via CacheBox. The default cache region we will use is the template cache, which you can connect to any distributed caching engine like: Redis, Couchbase, Mongo, Elastic, DB etc.


    out

    public coldbox.system.web.tasks.ScheduledTask out(any var)

    Send info messages to LogBox

    Overrides:
    out in class ScheduledTask
    Parameters:
    var - Variable/Message to send

    setCacheName

    public any setCacheName(any cacheName)

    Parameters:
    cacheName

    setCachebox

    public any setCachebox(any cachebox)

    Parameters:
    cachebox

    setController

    public any setController(any controller)

    Parameters:
    controller

    setEnvironments

    public any setEnvironments(array environments)

    Parameters:
    environments

    setLog

    public any setLog(any log)

    Parameters:
    log

    setServerFixation

    public any setServerFixation(boolean serverFixation)

    Parameters:
    serverFixation

    setServerLockTimeout

    public any setServerLockTimeout(numeric serverLockTimeout)

    Parameters:
    serverLockTimeout

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox