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 state
E - 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>

public class TimerTrigger<S,E> extends LifecycleObjectSupport implements Trigger<S,E>
Implementation of a Trigger capable of firing on a static periods.
Author:
Janne Valkealahti
  • 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 period
      count - the count
  • Method Details

    • getPeriod

      public long getPeriod()
    • getCount

      public int getCount()
    • evaluate

      public reactor.core.publisher.Mono<Boolean> evaluate(TriggerContext<S,E> context)
      Description copied from interface: Trigger
      Evaluate trigger.
      Specified by:
      evaluate in interface Trigger<S,E>
      Parameters:
      context - the context
      Returns:
      Mono for completion with true, if trigger is fired, false otherwise
    • addTriggerListener

      public void addTriggerListener(TriggerListener listener)
      Description copied from interface: Trigger
      Adds the trigger listener.
      Specified by:
      addTriggerListener in interface Trigger<S,E>
      Parameters:
      listener - the listener
    • getEvent

      public E getEvent()
      Description copied from interface: Trigger
      Gets the event associated with this trigger. It is possible that there are no event association.
      Specified by:
      getEvent in interface Trigger<S,E>
      Returns:
      the event
    • doPreStartReactively

      protected reactor.core.publisher.Mono<Void> doPreStartReactively()
      Description copied from class: LifecycleObjectSupport
      Subclasses may implement this for pre start logic.
      Overrides:
      doPreStartReactively in class LifecycleObjectSupport
      Returns:
      the mono for completion
    • doPreStopReactively

      protected reactor.core.publisher.Mono<Void> doPreStopReactively()
      Description copied from class: LifecycleObjectSupport
      Subclasses may implement this for pre stop logic.
      Overrides:
      doPreStopReactively in class LifecycleObjectSupport
      Returns:
      the mono for completion
    • arm

      public void arm()
      Description copied from interface: Trigger
      Arm a trigger. After trigger has been armed a TriggerListener may receive events.
      Specified by:
      arm in interface Trigger<S,E>
    • disarm

      public void disarm()
      Description copied from interface: Trigger
      Disarm a trigger. After trigger has been disarmed a TriggerListener will not receive events.
      Specified by:
      disarm in interface Trigger<S,E>