org.appng.api

## Interface ScheduledJob

-     public interface ScheduledJob

  A `ScheduledJob` is a (periodically or manually triggered) task that can be defined by an `Application`. The job's `jobDataMap` can contain any information that the job needs to be executed. For periodical execution, there are two pre-defined entries for the `jobDataMap`:
  - `cronExpression`
    A cron-expression describing when the `ScheduledJob` should be executed.
  - `enabled`
    If set to `true` and the `cronExpression` property is present (and valid), the `ScheduledJob` will automatically be scheduled when the platform starts.
  - `runOnce`
    If set to `true`, this job will only run once per cluster, i.e. it is not executed on each node, which is the default behavior.
  - `hardInterruptable`
    If set to `true`, this job can safely be interrupted, e.g when a `Site` is being reloaded. This is achieved by running the job in a separate thread and calling `Thread.interrupt()`.
  - `allowConcurrentExecutions`
    If set to `true`, multiple instances of this job can run concurrently (default is `false`).
  Author:
    Matthias Müller

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `execute(Site site, Application application)` This method actually executes the job.
    `String` | `getDescription()` Returns the description for this job.
    `Map<String,Object>` | `getJobDataMap()` Returns a `Map` containing some data needed the execute the job
    `default ScheduledJobResult` | `getResult()` This method is called after execution of the job.
    `void` | `setDescription(String description)` Sets the description for this job.
    `void` | `setJobDataMap(Map<String,Object> map)` Sets the `jobDataMap` for this job.

- - ### Method Detail

    - #### getDescription

          String getDescription()

      Returns the description for this job.
      Returns:
        the description

    - #### setDescription

          void setDescription(String description)

      Sets the description for this job.
      Parameters:
        `description` - the description

    - #### getJobDataMap

          Map<String,Object> getJobDataMap()

      Returns a `Map` containing some data needed the execute the job
      Returns:
        the `jobDataMap`

    - #### setJobDataMap

          void setJobDataMap(Map<String,Object> map)

      Sets the `jobDataMap` for this job.
      Parameters:
        `map` - `jobDataMap`

    - #### execute

          void execute(Site site,
                       Application application)
                throws Exception

      This method actually executes the job.
      Parameters:
        `site` - the `Site` to run within
        `application` - the `Application` to run within
      Throws:
        `Exception` - if any error occurs during job execution

    - #### getResult

          default ScheduledJobResult getResult()

      This method is called after execution of the job. It has to provide the result and optionally some custom information to be stored in the appNG database.
      Returns:
        the `ScheduledJobResult`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.