public class AnnotatedSaga<T> extends SagaLifecycle implements Saga<T>
interface
that allows for a POJO instance with annotated message handlers to act
as a Saga. The POJO instance can access static methods on SagaLifecycle
as long as it is access via the
execute(Consumer)
or invoke(Function)
methods.Constructor and Description |
---|
AnnotatedSaga(String sagaId,
Set<AssociationValue> associationValues,
T annotatedSaga,
TrackingToken trackingToken,
SagaModel<T> metaModel)
Creates an AnnotatedSaga instance to wrap the given
annotatedSaga , identifier with the given
sagaId and associated with the given associationValues . |
Modifier and Type | Method and Description |
---|---|
protected void |
doAssociateWith(AssociationValue property)
Registers a AssociationValue with the given saga.
|
protected void |
doEnd()
Marks the saga as ended.
|
protected void |
doRemoveAssociation(AssociationValue property)
Removes the given association from this Saga.
|
void |
execute(Consumer<T> invocation)
Execute the given
invocation against the root object of this Saga instance. |
AssociationValues |
getAssociationValues()
Returns a view on the Association Values for this saga instance.
|
String |
getSagaIdentifier()
Returns the unique identifier of this saga.
|
boolean |
handle(EventMessage<?> event)
Handle the given event.
|
<R> R |
invoke(Function<T,R> invocation)
Execute the given
invocation against the root object of this Saga instance. |
boolean |
isActive()
Indicates whether or not this saga is active.
|
T |
root()
Returns the (annotated) Saga instance.
|
TrackingToken |
trackingToken()
Returns the TrackingToken belonging to the EventMessage last processed by this instance, or
null if
this instance never handled an EventMessage, or if it received an EventMessage that doesn't carry a
TrackingToken. |
associateWith, associateWith, associateWith, end, execute, executeWithResult, getInstance, removeAssociationWith, removeAssociationWith
public AnnotatedSaga(String sagaId, Set<AssociationValue> associationValues, T annotatedSaga, TrackingToken trackingToken, SagaModel<T> metaModel)
annotatedSaga
, identifier with the given
sagaId
and associated with the given associationValues
. The metaModel
provides the
description of the structure of the Saga.sagaId
- The identifier of this Saga instanceassociationValues
- The current associations of this SagaannotatedSaga
- The object instance representing the SagatrackingToken
- The token identifying the position in a stream the saga has last processedmetaModel
- The model describing Saga structurepublic String getSagaIdentifier()
Saga
getSagaIdentifier
in interface Saga<T>
public AssociationValues getAssociationValues()
Saga
getAssociationValues
in interface Saga<T>
public <R> R invoke(Function<T,R> invocation)
Saga
invocation
against the root object of this Saga instance.public void execute(Consumer<T> invocation)
Saga
invocation
against the root object of this Saga instance.public final boolean handle(EventMessage<?> event)
Saga
public boolean isActive()
Saga
public TrackingToken trackingToken()
Saga
null
if
this instance never handled an EventMessage, or if it received an EventMessage that doesn't carry a
TrackingToken.trackingToken
in interface Saga<T>
public T root()
SagaLifecycle
.protected void doEnd()
doEnd
in class SagaLifecycle
protected void doAssociateWith(AssociationValue property)
doAssociateWith
in class SagaLifecycle
property
- The value to associate this saga with.protected void doRemoveAssociation(AssociationValue property)
doRemoveAssociation
in class SagaLifecycle
property
- the association value to remove from the saga.Copyright © 2010–2017. All rights reserved.