Class TimerTrigger<S,E>
java.lang.Object
org.springframework.statemachine.support.LifecycleObjectSupport
org.springframework.statemachine.trigger.TimerTrigger<S,E>
- Type Parameters:
S
- the type of stateE
- the type of event
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
,StateMachineReactiveLifecycle
,Trigger<S,
E>
Implementation of a
Trigger
capable of firing on a
static periods.- Author:
- Janne Valkealahti
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionTimerTrigger
(long period) Instantiates a new timer trigger.TimerTrigger
(long period, int count) Instantiates a new timer trigger. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTriggerListener
(TriggerListener listener) Adds the trigger listener.void
arm()
Arm a trigger.void
disarm()
Disarm a trigger.protected reactor.core.publisher.Mono<Void>
Subclasses may implement this for pre start logic.protected reactor.core.publisher.Mono<Void>
Subclasses may implement this for pre stop logic.reactor.core.publisher.Mono<Boolean>
evaluate
(TriggerContext<S, E> context) Evaluate trigger.int
getCount()
getEvent()
Gets the event associated with this trigger.long
Methods inherited from class org.springframework.statemachine.support.LifecycleObjectSupport
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, onInit, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactively
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Constructor Details
-
TimerTrigger
public TimerTrigger(long period) Instantiates a new timer trigger.- Parameters:
period
- the period in milliseconds
-
TimerTrigger
public TimerTrigger(long period, int count) Instantiates a new timer trigger.- Parameters:
period
- the periodcount
- the count
-
-
Method Details
-
getPeriod
public long getPeriod() -
getCount
public int getCount() -
evaluate
Description copied from interface:Trigger
Evaluate trigger. -
addTriggerListener
Description copied from interface:Trigger
Adds the trigger listener.- Specified by:
addTriggerListener
in interfaceTrigger<S,
E> - Parameters:
listener
- the listener
-
getEvent
Description copied from interface:Trigger
Gets the event associated with this trigger. It is possible that there are no event association. -
doPreStartReactively
Description copied from class:LifecycleObjectSupport
Subclasses may implement this for pre start logic.- Overrides:
doPreStartReactively
in classLifecycleObjectSupport
- Returns:
- the mono for completion
-
doPreStopReactively
Description copied from class:LifecycleObjectSupport
Subclasses may implement this for pre stop logic.- Overrides:
doPreStopReactively
in classLifecycleObjectSupport
- Returns:
- the mono for completion
-
arm
public void arm()Description copied from interface:Trigger
Arm a trigger. After trigger has been armed aTriggerListener
may receive events. -
disarm
public void disarm()Description copied from interface:Trigger
Disarm a trigger. After trigger has been disarmed aTriggerListener
will not receive events.
-