Class DynamicPeriodicTrigger
java.lang.Object
org.springframework.integration.util.DynamicPeriodicTrigger
- All Implemented Interfaces:
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
- Author:
- Gunnar Hillert, Gary Russell, Artem Bilan
-
Constructor Summary
ConstructorDescriptionDynamicPeriodicTrigger
(long period) Create a trigger with the given period in milliseconds.DynamicPeriodicTrigger
(Duration duration) Create a trigger with the provided duration. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return the duration.Get the initial duration.int
hashCode()
boolean
Return whether this trigger is fixed rate.nextExecution
(TriggerContext triggerContext) Return the time after which a task should run again.void
setDuration
(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
(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
Methods inherited from interface org.springframework.scheduling.Trigger
nextExecutionTime
-
Constructor Details
-
DynamicPeriodicTrigger
public DynamicPeriodicTrigger(long period) Create a trigger with the given period in milliseconds.- Parameters:
period
- Must not be negative
-
DynamicPeriodicTrigger
Create a trigger with the provided duration.- Parameters:
duration
- the duration.- Since:
- 5.1
-
-
Method Details
-
setInitialDuration
Specify the delay for the initial execution.- Parameters:
initialDuration
- the initial delay.- Since:
- 5.1
-
getDuration
Return the duration.- Returns:
- the duration.
- Since:
- 5.1
-
setDuration
Set the duration.- Parameters:
duration
- the duration.- Since:
- 5.1
-
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 rateboolean
flag.
-
isFixedRate
public boolean isFixedRate()Return whether this trigger is fixed rate.- Returns:
- the fixed rate.
-
nextExecution
Return the time after which a task should run again.- Specified by:
nextExecution
in interfaceTrigger
- Parameters:
triggerContext
- the trigger context to determine the previous state of schedule.- Returns:
- the next schedule instant.
-
equals
-
hashCode
public int hashCode()
-