Class DynamicPeriodicTrigger

java.lang.Object
org.springframework.integration.util.DynamicPeriodicTrigger
All Implemented Interfaces:
org.springframework.scheduling.Trigger

public class DynamicPeriodicTrigger
extends java.lang.Object
implements org.springframework.scheduling.Trigger
This is a dynamically changeable Trigger. It is based on the PeriodicTrigger implementations. However, the fields of this dynamic trigger are not final and the properties can be inspected and set via explicit getters and setters. Changes to the trigger take effect after the next execution.
Since:
4.2
  • Constructor Summary

    Constructors 
    Constructor Description
    DynamicPeriodicTrigger​(long period)
    Create a trigger with the given period in milliseconds.
    DynamicPeriodicTrigger​(java.time.Duration duration)
    Create a trigger with the provided duration.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object obj)  
    java.time.Duration getDuration()
    Return the duration.
    java.time.Duration getInitialDuration()
    Get the initial duration.
    int hashCode()  
    boolean isFixedRate()
    Return whether this trigger is fixed rate.
    java.util.Date nextExecutionTime​(org.springframework.scheduling.TriggerContext triggerContext)
    Return the time after which a task should run again.
    void setDuration​(java.time.Duration duration)
    Set the duration.
    void setFixedRate​(boolean fixedRate)
    Specify whether the periodic interval should be measured between the scheduled start times rather than between actual completion times.
    void setInitialDuration​(java.time.Duration initialDuration)
    Specify the delay for the initial execution.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DynamicPeriodicTrigger

      public DynamicPeriodicTrigger​(long period)
      Create a trigger with the given period in milliseconds.
      Parameters:
      period - Must not be negative
    • DynamicPeriodicTrigger

      public DynamicPeriodicTrigger​(java.time.Duration duration)
      Create a trigger with the provided duration.
      Parameters:
      duration - the duration.
      Since:
      5.1
  • Method Details

    • setInitialDuration

      public void setInitialDuration​(java.time.Duration initialDuration)
      Specify the delay for the initial execution.
      Parameters:
      initialDuration - the initial delay.
      Since:
      5.1
    • getDuration

      public java.time.Duration getDuration()
      Return the duration.
      Returns:
      the duration.
      Since:
      5.1
    • setDuration

      public void setDuration​(java.time.Duration duration)
      Set the duration.
      Parameters:
      duration - the duration.
      Since:
      5.1
    • getInitialDuration

      public java.time.Duration getInitialDuration()
      Get the initial duration.
      Returns:
      the initial duration.
      Since:
      5.1
    • setFixedRate

      public void setFixedRate​(boolean fixedRate)
      Specify whether the periodic interval should be measured between the scheduled start times rather than between actual completion times. The latter, "fixed delay" behavior, is the default.
      Parameters:
      fixedRate - the fixed rate boolean flag.
    • isFixedRate

      public boolean isFixedRate()
      Return whether this trigger is fixed rate.
      Returns:
      the fixed rate.
    • nextExecutionTime

      public java.util.Date nextExecutionTime​(org.springframework.scheduling.TriggerContext triggerContext)
      Return the time after which a task should run again.
      Specified by:
      nextExecutionTime in interface org.springframework.scheduling.Trigger
      Parameters:
      triggerContext - the trigger context to determine the previous state of schedule.
      Returns:
      the the next schedule date.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object