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.-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionTimerTrigger(long period) Instantiates a new timer trigger.TimerTrigger(long period, int count) Instantiates a new timer trigger. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTriggerListener(TriggerListener listener) Adds the trigger listener.voidarm()Arm a trigger.voiddisarm()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.intgetCount()getEvent()Gets the event associated with this trigger.longMethods inherited from class org.springframework.statemachine.support.LifecycleObjectSupport
afterPropertiesSet, destroy, doDestroy, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, onInit, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactivelyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:TriggerEvaluate trigger. -
addTriggerListener
Description copied from interface:TriggerAdds the trigger listener.- Specified by:
addTriggerListenerin interfaceTrigger<S,E> - Parameters:
listener- the listener
-
getEvent
Description copied from interface:TriggerGets the event associated with this trigger. It is possible that there are no event association. -
doPreStartReactively
Description copied from class:LifecycleObjectSupportSubclasses may implement this for pre start logic.- Overrides:
doPreStartReactivelyin classLifecycleObjectSupport- Returns:
- the mono for completion
-
doPreStopReactively
Description copied from class:LifecycleObjectSupportSubclasses may implement this for pre stop logic.- Overrides:
doPreStopReactivelyin classLifecycleObjectSupport- Returns:
- the mono for completion
-
arm
public void arm()Description copied from interface:TriggerArm a trigger. After trigger has been armed aTriggerListenermay receive events. -
disarm
public void disarm()Description copied from interface:TriggerDisarm a trigger. After trigger has been disarmed aTriggerListenerwill not receive events.
-