public class DynamicPeriodicTrigger extends Object implements Trigger
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.Constructor and Description |
---|
DynamicPeriodicTrigger(java.time.Duration duration)
Create a trigger with the provided duration.
|
DynamicPeriodicTrigger(long period)
Create a trigger with the given period in milliseconds.
|
DynamicPeriodicTrigger(long period,
TimeUnit timeUnit)
Deprecated.
in favor of
DynamicPeriodicTrigger(Duration) . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
java.time.Duration |
getDuration()
Return the duration.
|
long |
getInitialDelay()
Deprecated.
in favor of
getInitialDuration() . |
java.time.Duration |
getInitialDuration()
Get the initial duration.
|
long |
getPeriod()
Deprecated.
in favor of
getDuration() . |
TimeUnit |
getTimeUnit()
Deprecated.
- use
Duration instead. |
int |
hashCode() |
boolean |
isFixedRate()
Return whether this trigger is fixed rate.
|
Date |
nextExecutionTime(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 |
setInitialDelay(long initialDelay)
Deprecated.
in favor of
setInitialDuration(Duration) . |
void |
setInitialDuration(java.time.Duration initialDuration)
Specify the delay for the initial execution.
|
void |
setPeriod(long period)
Deprecated.
in favor of
setDuration(Duration) . |
void |
setTimeUnit(TimeUnit timeUnit)
Deprecated.
- use
Duration instead. |
public DynamicPeriodicTrigger(long period)
TimeUnit
will be initialized to TimeUnit.MILLISECONDS.period
- Must not be negative@Deprecated public DynamicPeriodicTrigger(long period, TimeUnit timeUnit)
DynamicPeriodicTrigger(Duration)
.setInitialDelay(long)
.period
- Must not be negativetimeUnit
- Must not be nullpublic DynamicPeriodicTrigger(java.time.Duration duration)
duration
- the duration.@Deprecated public void setInitialDelay(long initialDelay)
setInitialDuration(Duration)
.TimeUnit
. If no time unit was explicitly
provided upon instantiation, the default is milliseconds.initialDelay
- the initial delay in milliseconds.public void setInitialDuration(java.time.Duration initialDuration)
TimeUnit
. If no time unit was explicitly
provided upon instantiation, the default is milliseconds.initialDuration
- the initial delay in milliseconds.public java.time.Duration getDuration()
public void setDuration(java.time.Duration duration)
duration
- the duration.public java.time.Duration getInitialDuration()
public void setFixedRate(boolean fixedRate)
fixedRate
- the fixed rate boolean
flag.@Deprecated public long getPeriod()
getDuration()
.@Deprecated public void setPeriod(long period)
setDuration(Duration)
.TimeUnit
. If no time unit was explicitly
provided upon instantiation, the default is milliseconds.period
- Must not be negative@Deprecated public TimeUnit getTimeUnit()
Duration
instead.@Deprecated public void setTimeUnit(TimeUnit timeUnit)
Duration
instead.timeUnit
- the time unit.@Deprecated public long getInitialDelay()
getInitialDuration()
.public boolean isFixedRate()
public Date nextExecutionTime(TriggerContext triggerContext)
nextExecutionTime
in interface Trigger
triggerContext
- the trigger context to determine the previous state of schedule.