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 booleanequals(java.lang.Object obj)java.time.DurationgetDuration()Return the duration.java.time.DurationgetInitialDuration()Get the initial duration.inthashCode()booleanisFixedRate()Return whether this trigger is fixed rate.java.util.DatenextExecutionTime(org.springframework.scheduling.TriggerContext triggerContext)Return the time after which a task should run again.voidsetDuration(java.time.Duration duration)Set the duration.voidsetFixedRate(boolean fixedRate)Specify whether the periodic interval should be measured between the scheduled start times rather than between actual completion times.voidsetInitialDuration(java.time.Duration initialDuration)Specify the delay for the initial execution.
-
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 ratebooleanflag.
-
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:
nextExecutionTimein interfaceorg.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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-