Class AbstractPersistentFSMBase<S,D,E>

java.lang.Object
org.apache.pekko.persistence.fsm.AbstractPersistentFSMBase<S,D,E>
All Implemented Interfaces:
Actor, ActorLogging, PersistentFSMBase<S,D,E>, Listeners
Direct Known Subclasses:
AbstractPersistentFSM

public abstract class AbstractPersistentFSMBase<S,D,E> extends Object implements PersistentFSMBase<S,D,E>
Deprecated.
Use EventSourcedBehavior. Since Akka 2.6.0.
Java API: compatible with lambda expressions

Finite State Machine actor abstract base class.

  • Constructor Details

    • AbstractPersistentFSMBase

      public AbstractPersistentFSMBase()
      Deprecated.
  • Method Details

    • NullFunction

      public static <S, D> scala.PartialFunction<S,D> NullFunction()
      Deprecated.
      A partial function value which does not match anything and can be used to &ldquo;reset&rdquo; whenUnhandled and onTermination handlers.

      
       onTermination(FSM.NullFunction())
       
    • Event

      public PersistentFSM.Event$ Event()
      Deprecated.
      Specified by:
      Event in interface PersistentFSMBase<S,D,E>
    • StopEvent

      public PersistentFSM.StopEvent$ StopEvent()
      Deprecated.
      Specified by:
      StopEvent in interface PersistentFSMBase<S,D,E>
    • $minus$greater

      public PersistentFSM.$minus$greater$ $minus$greater()
      Deprecated.
      Description copied from interface: PersistentFSMBase
      This extractor is just convenience for matching a (S, S) pair, including a reminder what the new state is.
      Specified by:
      $minus$greater in interface PersistentFSMBase<S,D,E>
    • StateTimeout

      public PersistentFSM.StateTimeout$ StateTimeout()
      Deprecated.
      Description copied from interface: PersistentFSMBase
      This case object is received in case of a state timeout.
      Specified by:
      StateTimeout in interface PersistentFSMBase<S,D,E>
    • org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$Event_$eq

      protected void org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$Event_$eq(PersistentFSM.Event$ x$1)
      Deprecated.
      Specified by:
      org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$Event_$eq in interface PersistentFSMBase<S,D,E>
    • org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$StopEvent_$eq

      protected void org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$StopEvent_$eq(PersistentFSM.StopEvent$ x$1)
      Deprecated.
      Specified by:
      org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$StopEvent_$eq in interface PersistentFSMBase<S,D,E>
    • org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$StateTimeout_$eq

      protected void org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$StateTimeout_$eq(PersistentFSM.StateTimeout$ x$1)
      Deprecated.
      Description copied from interface: PersistentFSMBase
      This case object is received in case of a state timeout.
      Specified by:
      org$apache$pekko$persistence$fsm$PersistentFSMBase$_setter_$StateTimeout_$eq in interface PersistentFSMBase<S,D,E>
    • listeners

      protected Set<ActorRef> listeners()
      Deprecated.
      Specified by:
      listeners in interface Listeners
    • org$apache$pekko$routing$Listeners$_setter_$listeners_$eq

      protected void org$apache$pekko$routing$Listeners$_setter_$listeners_$eq(Set<ActorRef> x$1)
      Deprecated.
      Specified by:
      org$apache$pekko$routing$Listeners$_setter_$listeners_$eq in interface Listeners
    • context

      public ActorContext context()
      Deprecated.
      Description copied from interface: Actor
      Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as forward.

      WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!

      pekko.actor.ActorContext is the Scala API. getContext returns a pekko.actor.AbstractActor.ActorContext, which is the Java API of the actor context.

      Specified by:
      context in interface Actor
    • self

      public final ActorRef self()
      Deprecated.
      Description copied from interface: Actor
      The 'self' field holds the ActorRef for this actor.

      Can be used to send messages to itself:
       self ! message
       
      Specified by:
      self in interface Actor
    • org$apache$pekko$actor$Actor$_setter_$context_$eq

      protected void org$apache$pekko$actor$Actor$_setter_$context_$eq(ActorContext x$1)
      Deprecated.
      Description copied from interface: Actor
      Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as forward.

      WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!

      pekko.actor.ActorContext is the Scala API. getContext returns a pekko.actor.AbstractActor.ActorContext, which is the Java API of the actor context.

      Specified by:
      org$apache$pekko$actor$Actor$_setter_$context_$eq in interface Actor
    • org$apache$pekko$actor$Actor$_setter_$self_$eq

      protected final void org$apache$pekko$actor$Actor$_setter_$self_$eq(ActorRef x$1)
      Deprecated.
      Description copied from interface: Actor
      The 'self' field holds the ActorRef for this actor.

      Can be used to send messages to itself:
       self ! message
       
      Specified by:
      org$apache$pekko$actor$Actor$_setter_$self_$eq in interface Actor
    • getContext

      public AbstractActor.ActorContext getContext()
      Deprecated.
      Returns this AbstractActor's ActorContext The ActorContext is not thread safe so do not expose it outside of the AbstractActor.
    • getSelf

      public ActorRef getSelf()
      Deprecated.
      Returns the ActorRef for this actor.

      Same as self().

    • getSender

      public ActorRef getSender()
      Deprecated.
      The reference sender Actor of the currently processed message. This is always a legal destination to send to, even if there is no logical recipient for the reply, in which case it will be sent to the dead letter mailbox.

      Same as sender().

      WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!

    • when

      public final void when(S stateName, scala.PartialFunction<PersistentFSM.Event<D>,PersistentFSM.State<S,D,E>> stateFunction)
      Deprecated.
      Insert a new StateFunction at the end of the processing chain for the given state.

      Parameters:
      stateName - designator for the state
      stateFunction - partial function describing response to input
    • when

      public final void when(S stateName, FSMStateFunctionBuilder<S,D,E> stateFunctionBuilder)
      Deprecated.
      Insert a new StateFunction at the end of the processing chain for the given state.

      Parameters:
      stateName - designator for the state
      stateFunctionBuilder - partial function builder describing response to input
    • when

      public final void when(S stateName, scala.concurrent.duration.FiniteDuration stateTimeout, FSMStateFunctionBuilder<S,D,E> stateFunctionBuilder)
      Deprecated.
      Insert a new StateFunction at the end of the processing chain for the given state. If the stateTimeout parameter is set, entering this state without a differing explicit timeout setting will trigger a StateTimeout event; the same is true when using #stay.

      Parameters:
      stateName - designator for the state
      stateTimeout - default state timeout for this state
      stateFunctionBuilder - partial function builder describing response to input
    • startWith

      public final void startWith(S stateName, D stateData)
      Deprecated.
      Set initial state. Call this method from the constructor before the PersistentFSMBase.initialize() method. If different state is needed after a restart this method, followed by PersistentFSMBase.initialize(), can be used in the actor life cycle hooks pekko.actor.Actor#preStart and pekko.actor.Actor#postRestart.

      Parameters:
      stateName - initial state designator
      stateData - initial state data
    • startWith

      public final void startWith(S stateName, D stateData, scala.concurrent.duration.FiniteDuration timeout)
      Deprecated.
      Set initial state. Call this method from the constructor before the PersistentFSMBase.initialize() method. If different state is needed after a restart this method, followed by PersistentFSMBase.initialize(), can be used in the actor life cycle hooks pekko.actor.Actor#preStart and pekko.actor.Actor#postRestart.

      Parameters:
      stateName - initial state designator
      stateData - initial state data
      timeout - state timeout for the initial state, overriding the default timeout for that state
    • onTransition

      public final void onTransition(FSMTransitionHandlerBuilder<S> transitionHandlerBuilder)
      Deprecated.
      Add a handler which is called upon each state transition, i.e. not when staying in the same state.

      Multiple handlers may be installed, and every one of them will be called, not only the first one matching.

    • onTransition

      public final void onTransition(Procedure2<S,S> transitionHandler)
      Deprecated.
      Add a handler which is called upon each state transition, i.e. not when staying in the same state.

      Multiple handlers may be installed, and every one of them will be called, not only the first one matching.

    • whenUnhandled

      public final void whenUnhandled(FSMStateFunctionBuilder<S,D,E> stateFunctionBuilder)
      Deprecated.
      Set handler which is called upon reception of unhandled messages. Calling this method again will overwrite the previous contents.

      The current state may be queried using stateName.

    • onTermination

      public final void onTermination(FSMStopBuilder<S,D> stopBuilder)
      Deprecated.
      Set handler which is called upon termination of this FSM actor. Calling this method again will overwrite the previous contents.
    • matchEvent

      public final <ET, DT extends D> FSMStateFunctionBuilder<S,D,E> matchEvent(Class<ET> eventType, Class<DT> dataType, Predicate2<ET,DT> predicate, Function2<ET,DT,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches on an event and data type and a predicate.

      Parameters:
      eventType - the event type to match on
      dataType - the data type to match on
      predicate - a predicate to evaluate on the matched types
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEvent

      public final <ET, DT extends D> FSMStateFunctionBuilder<S,D,E> matchEvent(Class<ET> eventType, Class<DT> dataType, Function2<ET,DT,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches on an event and data type.

      Parameters:
      eventType - the event type to match on
      dataType - the data type to match on
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEvent

      public final <ET> FSMStateFunctionBuilder<S,D,E> matchEvent(Class<ET> eventType, Predicate2<ET,D> predicate, Function2<ET,D,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches if the event type and predicate matches.

      Parameters:
      eventType - the event type to match on
      predicate - a predicate that will be evaluated on the data and the event
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEvent

      public final <ET> FSMStateFunctionBuilder<S,D,E> matchEvent(Class<ET> eventType, Function2<ET,D,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches if the event type matches.

      Parameters:
      eventType - the event type to match on
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEvent

      public final FSMStateFunctionBuilder<S,D,E> matchEvent(Predicate2<Object,D> predicate, Function2<Object,D,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches if the predicate matches.

      Parameters:
      predicate - a predicate that will be evaluated on the data and the event
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEvent

      public final <DT extends D> FSMStateFunctionBuilder<S,D,E> matchEvent(List<Object> eventMatches, Class<DT> dataType, Function2<Object,DT,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches on the data type and if any of the event types in the list match or any of the event instances in the list compares equal.

      Parameters:
      eventMatches - a list of types or instances to match against
      dataType - the data type to match on
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEvent

      public final FSMStateFunctionBuilder<S,D,E> matchEvent(List<Object> eventMatches, Function2<Object,D,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches if any of the event types in the list match or any of the event instances in the list compares equal.

      Parameters:
      eventMatches - a list of types or instances to match against
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEventEquals

      public final <Ev, DT extends D> FSMStateFunctionBuilder<S,D,E> matchEventEquals(Ev event, Class<DT> dataType, Function2<Ev,DT,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches on the data type and if the event compares equal.

      Parameters:
      event - an event to compare equal against
      dataType - the data type to match on
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchEventEquals

      public final <Ev> FSMStateFunctionBuilder<S,D,E> matchEventEquals(Ev event, Function2<Ev,D,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches if the event compares equal.

      Parameters:
      event - an event to compare equal against
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchAnyEvent

      public final FSMStateFunctionBuilder<S,D,E> matchAnyEvent(Function2<Object,D,PersistentFSM.State<S,D,E>> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStateFunctionBuilder with the first case statement set.

      A case statement that matches on any type of event.

      Parameters:
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchState

      public final FSMTransitionHandlerBuilder<S> matchState(S fromState, S toState, Effect apply)
      Deprecated.
      Create an pekko.japi.pf.FSMTransitionHandlerBuilder with the first case statement set.

      A case statement that matches on a from state and a to state.

      Parameters:
      fromState - the from state to match on
      toState - the to state to match on
      apply - an action to apply when the states match
      Returns:
      the builder with the case statement added
    • matchState

      public final FSMTransitionHandlerBuilder<S> matchState(S fromState, S toState, Procedure2<S,S> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMTransitionHandlerBuilder with the first case statement set.

      A case statement that matches on a from state and a to state.

      Parameters:
      fromState - the from state to match on
      toState - the to state to match on
      apply - an action to apply when the states match
      Returns:
      the builder with the case statement added
    • matchStop

      public final FSMStopBuilder<S,D> matchStop(PersistentFSM.Reason reason, Procedure2<S,D> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStopBuilder with the first case statement set.

      A case statement that matches on an PersistentFSM.Reason.

      Parameters:
      reason - the reason for the termination
      apply - an action to apply to the event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchStop

      public final <RT extends PersistentFSM.Reason> FSMStopBuilder<S,D> matchStop(Class<RT> reasonType, Procedure3<RT,S,D> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStopBuilder with the first case statement set.

      A case statement that matches on a reason type.

      Parameters:
      reasonType - the reason type to match on
      apply - an action to apply to the reason, event and state data if there is a match
      Returns:
      the builder with the case statement added
    • matchStop

      public final <RT extends PersistentFSM.Reason> FSMStopBuilder<S,D> matchStop(Class<RT> reasonType, Predicate<RT> predicate, Procedure3<RT,S,D> apply)
      Deprecated.
      Create an pekko.japi.pf.FSMStopBuilder with the first case statement set.

      A case statement that matches on a reason type and a predicate.

      Parameters:
      reasonType - the reason type to match on
      apply - an action to apply to the reason, event and state data if there is a match
      predicate - a predicate that will be evaluated on the reason if the type matches
      Returns:
      the builder with the case statement added
    • matchData

      public final <DT extends D> UnitPFBuilder<D> matchData(Class<DT> dataType, Procedure<DT> apply)
      Deprecated.
      Create a pekko.japi.pf.UnitPFBuilder with the first case statement set.

      Parameters:
      dataType - a type to match the argument against
      apply - an action to apply to the argument if the type matches
      Returns:
      a builder with the case statement added
    • matchData

      public final <DT extends D> UnitPFBuilder<D> matchData(Class<DT> dataType, Predicate<DT> predicate, Procedure<DT> apply)
      Deprecated.
      Create a pekko.japi.pf.UnitPFBuilder with the first case statement set.

      Parameters:
      dataType - a type to match the argument against
      predicate - a predicate that will be evaluated on the argument if the type matches
      apply - an action to apply to the argument if the type and predicate matches
      Returns:
      a builder with the case statement added
    • goTo

      public final PersistentFSM.State<S,D,E> goTo(S nextStateName)
      Deprecated.
      Produce transition to other state. Return this from a state function in order to effect the transition.

      Parameters:
      nextStateName - state designator for the next state
      Returns:
      state transition descriptor
    • startTimerWithFixedDelay

      public void startTimerWithFixedDelay(String name, Object msg, Duration delay)
      Deprecated.
      Schedules a message to be sent repeatedly to the self actor with a fixed delay between messages.

      It will not compensate the delay between messages if scheduling is delayed longer than specified for some reason. The delay between sending of subsequent messages will always be (at least) the given delay.

      In the long run, the frequency of messages will generally be slightly lower than the reciprocal of the specified delay.

      Each timer has a name and if a new timer with same name is started the previous is cancelled. It is guaranteed that a message from the previous timer is not received, even if it was already enqueued in the mailbox when the new timer was started.

    • startTimerAtFixedRate

      public void startTimerAtFixedRate(String name, Object msg, Duration interval)
      Deprecated.
      Schedules a message to be sent repeatedly to the self actor with a given frequency.

      It will compensate the delay for a subsequent message if the sending of previous message was delayed more than specified. In such cases, the actual message interval will differ from the interval passed to the method.

      If the execution is delayed longer than the interval, the subsequent message will be sent immediately after the prior one. This also has the consequence that after long garbage collection pauses or other reasons when the JVM was suspended all "missed" messages will be sent when the process wakes up again.

      In the long run, the frequency of messages will be exactly the reciprocal of the specified interval.

      Warning: startTimerAtFixedRate can result in bursts of scheduled messages after long garbage collection pauses, which may in worst case cause undesired load on the system. Therefore startTimerWithFixedDelay is often preferred.

      Each timer has a name and if a new timer with same name is started the previous is cancelled. It is guaranteed that a message from the previous timer is not received, even if it was already enqueued in the mailbox when the new timer was started.

    • startSingleTimer

      public void startSingleTimer(String name, Object msg, Duration delay)
      Deprecated.
      Start a timer that will send msg once to the self actor after the given delay.

      Each timer has a name and if a new timer with same name is started the previous is cancelled. It is guaranteed that a message from the previous timer is not received, even if it was already enqueued in the mailbox when the new timer was started.

    • setTimer

      public final void setTimer(String name, Object msg, scala.concurrent.duration.FiniteDuration timeout)
      Deprecated.
      Use startSingleTimer instead. Since Akka 2.6.0.
      Schedule named timer to deliver message after given delay, possibly repeating. Any existing timer with the same name will automatically be canceled before adding the new timer.
      Parameters:
      name - identifier to be used with cancelTimer()
      msg - message to be delivered
      timeout - delay of first message delivery and between subsequent messages
    • Normal

      public PersistentFSM.Reason Normal()
      Deprecated.
      Default reason if calling stop().
    • Shutdown

      public PersistentFSM.Reason Shutdown()
      Deprecated.
      Reason given when someone was calling system.stop(fsm) from outside; also applies to Stop supervision directive.