org.springframework.cloud.dataflow.rest.client.dsl.task

## Class TaskSchedule

- java.lang.Object
- - org.springframework.cloud.dataflow.rest.client.dsl.task.TaskSchedule

- All Implemented Interfaces:
    AutoCloseable

      public class TaskSchedule
      extends Object
      implements AutoCloseable

  Represents a Scheduled Task defined on DataFlow server. Tasks can be scheduled defined with the help of a fluent style builder pattern or use it to retrieve and manage existing task schedules. For for instance to define a new task task schedule:

            TaskScheduleBuilder taskScheduleBuilder = TaskSchedule.builder(dataFlowOperations);
           	try (Task task = Task.builder(dataFlowOperations).name("myTask").definition("timestamp").build();
                 TaskSchedule taskSchedule = taskScheduleBuilder.scheduleName("mySchedule").task(task).build()) {

                 taskSchedule.schedule("56 20 ? * *", Collections.emptyMap());

                 TaskSchedule retrievedSchedule = taskScheduleBuilder.findByScheduleName(taskSchedule.getScheduleName());
                 taskSchedule.unschedule();
             }

  Author:
    Christian Tzolov

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CRON_EXPRESSION_KEY`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static TaskScheduleBuilder` | `builder(DataFlowOperations dataFlowOperations)` Fluent API method to create a `TaskScheduleBuilder`.
    `void` | `close()`
    `String` | `getScheduleName()`
    `Map<String,String>` | `getScheduleProperties()`
    `Task` | `getTask()`
    `boolean` | `isScheduled()`
    `void` | `schedule(String cronExpression, Map<String,String> scheduleProperties, String... taskArgs)` Schedule the task.
    `void` | `unschedule()` Unschedule a previously scheduled task.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### CRON_EXPRESSION_KEY

          public static final String CRON_EXPRESSION_KEY

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### builder

          public static TaskScheduleBuilder builder(DataFlowOperations dataFlowOperations)

      Fluent API method to create a `TaskScheduleBuilder`.
      Parameters:
        `dataFlowOperations` - `DataFlowOperations` Data Flow Rest client instance.
      Returns:
        A fluent style builder to create tasks.

    - #### schedule

          public void schedule(String cronExpression,
                               Map<String,String> scheduleProperties,
                               String... taskArgs)

      Schedule the task.
      Parameters:
        `scheduleProperties` - Scheduling properties to use.
        `taskArgs` - task arguments to pass on schedule run.
        `cronExpression` - the cron expression used to schedule the task execution.

    - #### unschedule

          public void unschedule()

      Unschedule a previously scheduled task.

    - #### isScheduled

          public boolean isScheduled()

      Returns:
        Returns true if the task is being scheduled or false otherwise.

    - #### getScheduleProperties

          public Map<String,String> getScheduleProperties()

      Returns:
        Returns the schedule properties.

    - #### getTask

          public Task getTask()

      Returns:
        Get the scheduled task.

    - #### getScheduleName

          public String getScheduleName()

    - #### close

          public void close()

      Specified by:
        `close` in interface `AutoCloseable`

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.