AbstractStatefulReactor

public abstract class AbstractStatefulReactor<I, S extends Message, B extends ValidatingBuilder<S>> extends AbstractEventReactor

An abstract base for AbstractEventReactors which have state and require delivering the messages through an Inbox.

Inheritors

Constructors

Link copied to clipboard
protected void AbstractStatefulReactor(TypeUrl stateType)
Creates a new instance of the reactor and initializes the Inbox for it.

Functions

Link copied to clipboard
protected B builder()
Returns the current state as a ValidatingBuilder for the respective message.
Link copied to clipboard
public DispatchOutcome dispatch(EventEnvelope event)
Dispatches the message contained in the passed envelope and returns the outcome.
Link copied to clipboard
protected final void flushState()
Immediately writes the changes made to the current builder to the storage.
Link copied to clipboard
protected abstract Optional<S> load(I id)
Loads the state from the storage by ID.
Link copied to clipboard
protected abstract B newStateBuilderWith(I id)
Creates a new instance of the respective state ValidatingBuilder and sets the passed identifier to it.
Link copied to clipboard
protected abstract ImmutableSet<I> route(EventEnvelope event)
Selects the target to which the event should be dispatched.
Link copied to clipboard
protected abstract void store(S updatedState)
Stores the passed state in the storage.

Inherited functions

Link copied to clipboard
public boolean canDispatch(E envelope)
Checks if this dispatcher can dispatch the given message.
Link copied to clipboard
public void checkNotRegistered()
Verifies that this instance is NOT registered yet.
Link copied to clipboard
public void checkRegistered()
Verifies that this instance is already registered.
Link copied to clipboard
public abstract DispatchOutcome dispatch(E envelope)
Dispatches the message contained in the passed envelope and returns the outcome.
Link copied to clipboard
public boolean dispatchesEvents()
Verifies if this instance dispatches at least one event.
Link copied to clipboard
public boolean dispatchesExternalEvents()
Verifies if this instance dispatches at least one external event.
Link copied to clipboard
public ImmutableSet<EventClass> domesticEventClasses()
Obtains classes of domestic events processed by this dispatcher.
Link copied to clipboard
public ImmutableSet<EventClass> eventClasses()
Obtains classes of all events processed by this dispatcher.
Link copied to clipboard
public ImmutableSet<EventClass> externalEventClasses()
Obtains classes of external events processed by this dispatcher.
Link copied to clipboard
public boolean isRegistered()
Determines if this instance is already registered with a Bounded Context.
Link copied to clipboard
public abstract ImmutableSet<C> messageClasses()
public ImmutableSet<EventClass> messageClasses()
Obtains a set of message classes that can be processed by this dispatcher.
Link copied to clipboard
public Nothing nothing()
Obtains the io.spine.server.model.
Link copied to clipboard
public ImmutableSet<EventClass> producedEvents()
Obtains classes of the events produced by this object.
Link copied to clipboard
public Any producerId()
Obtains the name of this reactor, packed to Any.
Link copied to clipboard
protected void registerIn(Stand stand)
Registers this reactor in Stand as an event producer.
Link copied to clipboard
public void registerWith(BoundedContext context)
Registers this instance as a part of the given Bounded Context.
Link copied to clipboard
public Version version()
Returns a zero version.