org.springframework.scheduling.config

## 类 ScheduledTaskRegistrar

- java.lang.Object
- - org.springframework.scheduling.config.ScheduledTaskRegistrar

- 所有已实现的接口:
    org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, ScheduledTaskHolder
  直接已知子类:
    ContextLifecycleScheduledTaskRegistrar

      public class ScheduledTaskRegistrar
      extends Object
      implements ScheduledTaskHolder, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

  Helper bean for registering tasks with a `TaskScheduler`, typically using cron expressions.

  As of Spring 3.1, `ScheduledTaskRegistrar` has a more prominent user-facing role when used in conjunction with the @`EnableAsync` annotation and its `SchedulingConfigurer` callback interface.

  从以下版本开始:
    3.0
  作者:
    Juergen Hoeller, Chris Beams, Tobias Montagna-Hay
  另请参阅:
    `EnableAsync`, `SchedulingConfigurer`

- - ### 构造器概要

    构造器
    构造器和说明
    `ScheduledTaskRegistrar()`

  - ### 方法概要

    所有方法 实例方法 具体方法 已过时的方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `addCronTask(CronTask task)` Add a `CronTask`.
    `void` | `addCronTask(Runnable task, String expression)` Add a Runnable task to be triggered per the given cron expression
    `void` | `addFixedDelayTask(IntervalTask task)` Add a fixed-delay `IntervalTask`.
    `void` | `addFixedDelayTask(Runnable task, long delay)` Add a Runnable task to be triggered with the given fixed delay.
    `void` | `addFixedRateTask(IntervalTask task)` Add a fixed-rate `IntervalTask`.
    `void` | `addFixedRateTask(Runnable task, long interval)` Add a `Runnable` task to be triggered at the given fixed-rate interval.
    `void` | `addTriggerTask(Runnable task, Trigger trigger)` Add a Runnable task to be triggered per the given `Trigger`.
    `void` | `addTriggerTask(TriggerTask task)` Add a `TriggerTask`.
    `void` | `afterPropertiesSet()` Calls `scheduleTasks()` at bean construction time.
    `void` | `destroy()`
    `List<CronTask>` | `getCronTaskList()` Get the cron tasks as an unmodifiable list of `CronTask` objects.
    `List<IntervalTask>` | `getFixedDelayTaskList()` Get the fixed-delay tasks as an unmodifiable list of `IntervalTask` objects.
    `List<IntervalTask>` | `getFixedRateTaskList()` Get the fixed-rate tasks as an unmodifiable list of `IntervalTask` objects.
    `Set<ScheduledTask>` | `getScheduledTasks()` Return all locally registered tasks that have been scheduled by this registrar.
    `TaskScheduler` | `getScheduler()` Return the `TaskScheduler` instance for this registrar (may be `null`).
    `List<TriggerTask>` | `getTriggerTaskList()` Get the trigger tasks as an unmodifiable list of `TriggerTask` objects.
    `boolean` | `hasTasks()` Return whether this `ScheduledTaskRegistrar` has any tasks registered.
    `ScheduledTask` | `scheduleCronTask(CronTask task)` Schedule the specified cron task, either right away if possible or on initialization of the scheduler.
    `ScheduledTask` | `scheduleFixedDelayTask(FixedDelayTask task)` Schedule the specified fixed-delay task, either right away if possible or on initialization of the scheduler.
    `ScheduledTask` | `scheduleFixedDelayTask(IntervalTask task)` 已过时。 as of 5.0.2, in favor of `scheduleFixedDelayTask(FixedDelayTask)`
    `ScheduledTask` | `scheduleFixedRateTask(FixedRateTask task)` Schedule the specified fixed-rate task, either right away if possible or on initialization of the scheduler.
    `ScheduledTask` | `scheduleFixedRateTask(IntervalTask task)` 已过时。 as of 5.0.2, in favor of `scheduleFixedRateTask(FixedRateTask)`
    `protected void` | `scheduleTasks()` Schedule all registered tasks against the underlying task scheduler.
    `ScheduledTask` | `scheduleTriggerTask(TriggerTask task)` Schedule the specified trigger task, either right away if possible or on initialization of the scheduler.
    `void` | `setCronTasks(Map<Runnable,String> cronTasks)` Specify triggered tasks as a Map of Runnables (the tasks) and cron expressions.
    `void` | `setCronTasksList(List<CronTask> cronTasks)` Specify triggered tasks as a list of `CronTask` objects.
    `void` | `setFixedDelayTasks(Map<Runnable,Long> fixedDelayTasks)` Specify triggered tasks as a Map of Runnables (the tasks) and fixed-delay values.
    `void` | `setFixedDelayTasksList(List<IntervalTask> fixedDelayTasks)` Specify fixed-delay tasks as a list of `IntervalTask` objects.
    `void` | `setFixedRateTasks(Map<Runnable,Long> fixedRateTasks)` Specify triggered tasks as a Map of Runnables (the tasks) and fixed-rate values.
    `void` | `setFixedRateTasksList(List<IntervalTask> fixedRateTasks)` Specify fixed-rate tasks as a list of `IntervalTask` objects.
    `void` | `setScheduler(Object scheduler)` Set the `TaskScheduler` to register scheduled tasks with, or a `ScheduledExecutorService` to be wrapped as a `TaskScheduler`.
    `void` | `setTaskScheduler(TaskScheduler taskScheduler)` Set the `TaskScheduler` to register scheduled tasks with.
    `void` | `setTriggerTasks(Map<Runnable,Trigger> triggerTasks)` Specify triggered tasks as a Map of Runnables (the tasks) and Trigger objects (typically custom implementations of the `Trigger` interface).
    `void` | `setTriggerTasksList(List<TriggerTask> triggerTasks)` Specify triggered tasks as a list of `TriggerTask` objects.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### ScheduledTaskRegistrar

          public ScheduledTaskRegistrar()

  - ### 方法详细资料

    - #### setTaskScheduler

          public void setTaskScheduler(TaskScheduler taskScheduler)

      Set the `TaskScheduler` to register scheduled tasks with.

    - #### setScheduler

          public void setScheduler(@Nullable
                                   Object scheduler)

      Set the `TaskScheduler` to register scheduled tasks with, or a `ScheduledExecutorService` to be wrapped as a `TaskScheduler`.

    - #### getScheduler

          @Nullable
          public TaskScheduler getScheduler()

      Return the `TaskScheduler` instance for this registrar (may be `null`).

    - #### setTriggerTasks

          public void setTriggerTasks(Map<Runnable,Trigger> triggerTasks)

      Specify triggered tasks as a Map of Runnables (the tasks) and Trigger objects (typically custom implementations of the `Trigger` interface).

    - #### setTriggerTasksList

          public void setTriggerTasksList(List<TriggerTask> triggerTasks)

      Specify triggered tasks as a list of `TriggerTask` objects. Primarily used by `<task:*>` namespace parsing.
      从以下版本开始:
        3.2
      另请参阅:
        `ScheduledTasksBeanDefinitionParser`

    - #### getTriggerTaskList

          public List<TriggerTask> getTriggerTaskList()

      Get the trigger tasks as an unmodifiable list of `TriggerTask` objects.
      返回:
        the list of tasks (never `null`)
      从以下版本开始:
        4.2

    - #### setCronTasks

          public void setCronTasks(Map<Runnable,String> cronTasks)

      Specify triggered tasks as a Map of Runnables (the tasks) and cron expressions.
      另请参阅:
        `CronTrigger`

    - #### setCronTasksList

          public void setCronTasksList(List<CronTask> cronTasks)

      Specify triggered tasks as a list of `CronTask` objects. Primarily used by `<task:*>` namespace parsing.
      从以下版本开始:
        3.2
      另请参阅:
        `ScheduledTasksBeanDefinitionParser`

    - #### getCronTaskList

          public List<CronTask> getCronTaskList()

      Get the cron tasks as an unmodifiable list of `CronTask` objects.
      返回:
        the list of tasks (never `null`)
      从以下版本开始:
        4.2

    - #### setFixedRateTasks

          public void setFixedRateTasks(Map<Runnable,Long> fixedRateTasks)

      Specify triggered tasks as a Map of Runnables (the tasks) and fixed-rate values.
      另请参阅:
        `TaskScheduler.scheduleAtFixedRate(Runnable, long)`

    - #### setFixedRateTasksList

          public void setFixedRateTasksList(List<IntervalTask> fixedRateTasks)

      Specify fixed-rate tasks as a list of `IntervalTask` objects. Primarily used by `<task:*>` namespace parsing.
      从以下版本开始:
        3.2
      另请参阅:
        `ScheduledTasksBeanDefinitionParser`

    - #### getFixedRateTaskList

          public List<IntervalTask> getFixedRateTaskList()

      Get the fixed-rate tasks as an unmodifiable list of `IntervalTask` objects.
      返回:
        the list of tasks (never `null`)
      从以下版本开始:
        4.2

    - #### setFixedDelayTasks

          public void setFixedDelayTasks(Map<Runnable,Long> fixedDelayTasks)

      Specify triggered tasks as a Map of Runnables (the tasks) and fixed-delay values.
      另请参阅:
        `TaskScheduler.scheduleWithFixedDelay(Runnable, long)`

    - #### setFixedDelayTasksList

          public void setFixedDelayTasksList(List<IntervalTask> fixedDelayTasks)

      Specify fixed-delay tasks as a list of `IntervalTask` objects. Primarily used by `<task:*>` namespace parsing.
      从以下版本开始:
        3.2
      另请参阅:
        `ScheduledTasksBeanDefinitionParser`

    - #### getFixedDelayTaskList

          public List<IntervalTask> getFixedDelayTaskList()

      Get the fixed-delay tasks as an unmodifiable list of `IntervalTask` objects.
      返回:
        the list of tasks (never `null`)
      从以下版本开始:
        4.2

    - #### addTriggerTask

          public void addTriggerTask(Runnable task,
                                     Trigger trigger)

      Add a Runnable task to be triggered per the given `Trigger`.
      另请参阅:
        `TaskScheduler.scheduleAtFixedRate(Runnable, long)`

    - #### addTriggerTask

          public void addTriggerTask(TriggerTask task)

      Add a `TriggerTask`.
      从以下版本开始:
        3.2
      另请参阅:
        `TaskScheduler.scheduleAtFixedRate(Runnable, long)`

    - #### addCronTask

          public void addCronTask(Runnable task,
                                  String expression)

      Add a Runnable task to be triggered per the given cron expression

    - #### addCronTask

          public void addCronTask(CronTask task)

      Add a `CronTask`.
      从以下版本开始:
        3.2

    - #### addFixedRateTask

          public void addFixedRateTask(Runnable task,
                                       long interval)

      Add a `Runnable` task to be triggered at the given fixed-rate interval.
      另请参阅:
        `TaskScheduler.scheduleAtFixedRate(Runnable, long)`

    - #### addFixedRateTask

          public void addFixedRateTask(IntervalTask task)

      Add a fixed-rate `IntervalTask`.
      从以下版本开始:
        3.2
      另请参阅:
        `TaskScheduler.scheduleAtFixedRate(Runnable, long)`

    - #### addFixedDelayTask

          public void addFixedDelayTask(Runnable task,
                                        long delay)

      Add a Runnable task to be triggered with the given fixed delay.
      另请参阅:
        `TaskScheduler.scheduleWithFixedDelay(Runnable, long)`

    - #### addFixedDelayTask

          public void addFixedDelayTask(IntervalTask task)

      Add a fixed-delay `IntervalTask`.
      从以下版本开始:
        3.2
      另请参阅:
        `TaskScheduler.scheduleWithFixedDelay(Runnable, long)`

    - #### hasTasks

          public boolean hasTasks()

      Return whether this `ScheduledTaskRegistrar` has any tasks registered.
      从以下版本开始:
        3.2

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Calls `scheduleTasks()` at bean construction time.
      指定者:
        `afterPropertiesSet` 在接口中 `org.springframework.beans.factory.InitializingBean`

    - #### scheduleTasks

          protected void scheduleTasks()

      Schedule all registered tasks against the underlying task scheduler.

    - #### scheduleTriggerTask

          @Nullable
          public ScheduledTask scheduleTriggerTask(TriggerTask task)

      Schedule the specified trigger task, either right away if possible or on initialization of the scheduler.
      返回:
        a handle to the scheduled task, allowing to cancel it
      从以下版本开始:
        4.3

    - #### scheduleCronTask

          @Nullable
          public ScheduledTask scheduleCronTask(CronTask task)

      Schedule the specified cron task, either right away if possible or on initialization of the scheduler.
      返回:
        a handle to the scheduled task, allowing to cancel it (or `null` if processing a previously registered task)
      从以下版本开始:
        4.3

    - #### scheduleFixedRateTask

          @Deprecated
           @Nullable
          public ScheduledTask scheduleFixedRateTask(IntervalTask task)

      已过时。 as of 5.0.2, in favor of `scheduleFixedRateTask(FixedRateTask)`
      Schedule the specified fixed-rate task, either right away if possible or on initialization of the scheduler.
      返回:
        a handle to the scheduled task, allowing to cancel it (or `null` if processing a previously registered task)
      从以下版本开始:
        4.3

    - #### scheduleFixedRateTask

          @Nullable
          public ScheduledTask scheduleFixedRateTask(FixedRateTask task)

      Schedule the specified fixed-rate task, either right away if possible or on initialization of the scheduler.
      返回:
        a handle to the scheduled task, allowing to cancel it (or `null` if processing a previously registered task)
      从以下版本开始:
        5.0.2

    - #### scheduleFixedDelayTask

          @Deprecated
           @Nullable
          public ScheduledTask scheduleFixedDelayTask(IntervalTask task)

      已过时。 as of 5.0.2, in favor of `scheduleFixedDelayTask(FixedDelayTask)`
      Schedule the specified fixed-delay task, either right away if possible or on initialization of the scheduler.
      返回:
        a handle to the scheduled task, allowing to cancel it (or `null` if processing a previously registered task)
      从以下版本开始:
        4.3

    - #### scheduleFixedDelayTask

          @Nullable
          public ScheduledTask scheduleFixedDelayTask(FixedDelayTask task)

      Schedule the specified fixed-delay task, either right away if possible or on initialization of the scheduler.
      返回:
        a handle to the scheduled task, allowing to cancel it (or `null` if processing a previously registered task)
      从以下版本开始:
        5.0.2

    - #### getScheduledTasks

          public Set<ScheduledTask> getScheduledTasks()

      Return all locally registered tasks that have been scheduled by this registrar.
      指定者:
        `getScheduledTasks` 在接口中 `ScheduledTaskHolder`
      从以下版本开始:
        5.0.2
      另请参阅:
        `addTriggerTask(java.lang.Runnable, org.springframework.scheduling.Trigger)`, `addCronTask(java.lang.Runnable, java.lang.String)`, `addFixedRateTask(java.lang.Runnable, long)`, `addFixedDelayTask(java.lang.Runnable, long)`

    - #### destroy

          public void destroy()

      指定者:
        `destroy` 在接口中 `org.springframework.beans.factory.DisposableBean`