Interface SagaModel<T>
- Type Parameters:
T- The saga type
public interface SagaModel<T>
Interface of a model that describes a Saga of type
T. Use the SagaModel to obtain associations and
event handlers for the Saga.-
Method Summary
Modifier and TypeMethodDescriptionList<MessageHandlingMember<? super T>> findHandlerMethods(EventMessage event, ProcessingContext context) Returns aListofMessageHandlingMemberthat can handle the given event.default booleanhasHandlerMethod(EventMessage eventMessage, ProcessingContext context) Indicates whether the Saga described by this model has a handler for the giveneventMessageReturns the factory that created this model.payloadTypeFor(QualifiedName eventName) Returns the payload type of the handler that is declared for events with the giveneventName.resolveAssociation(EventMessage eventMessage, ProcessingContext context) Returns theQualifiedNamesof alleventssupported by the Saga described by this model, that is, the events for which the Saga declares a@SagaEventHandlermethod.
-
Method Details
-
resolveAssociation
Returns theAssociationValueused to find sagas of typeTthat can handle the giveneventMessage. If the saga type does not handle events of this type an empty Optional is returned.- Parameters:
eventMessage- The event to find the association value for.context- TheProcessingContextin which the event is being processed.- Returns:
- Optional of the AssociationValue for the event, or an empty Optional if the saga doesn't handle the event
-
findHandlerMethods
List<MessageHandlingMember<? super T>> findHandlerMethods(EventMessage event, ProcessingContext context) Returns aListofMessageHandlingMemberthat can handle the given event.- Parameters:
event- TheEventMessageto be handled.context- TheProcessingContextin which the event is being processed.- Returns:
- Event message handlers for the given
event.
-
hasHandlerMethod
Indicates whether the Saga described by this model has a handler for the giveneventMessage- Parameters:
eventMessage- The message to check the availability of a handler for.context- TheProcessingContextin which the event is being processed.- Returns:
trueif there the Saga has a handler for this message, otherwisefalse.
-
modelFactory
SagaMetaModelFactory modelFactory()Returns the factory that created this model.- Returns:
- The factory that made this model
-
supportedEvents
Set<QualifiedName> supportedEvents()Returns theQualifiedNamesof alleventssupported by the Saga described by this model, that is, the events for which the Saga declares a@SagaEventHandlermethod.- Returns:
- the
QualifiedNamesof alleventssupported by the Saga described by this model
-
payloadTypeFor
Returns the payload type of the handler that is declared for events with the giveneventName.Sagas resolve handlers and association values from the payload's runtime type. An event read from an event store carries a serialized payload, which has to be converted to this type first.
- Parameters:
eventName- the qualified name of the event- Returns:
- the handler's payload type, or empty if no handler is declared for the given name
-