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 |
---|---|
boolean |
canHandle(EventMessage<?> event)
Indicates whether this listener can handle the given event message
|
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()
Retrieve a
String denoting the identifier of this Saga. |
void |
handle(EventMessage<?> event)
Process 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. |
protected String |
type()
Retrieve a
String denoting the type of this Saga. |
associateWith, associateWith, associateWith, describeScope, end, execute, getInstance, removeAssociationWith, removeAssociationWith
describeCurrentScope, endScope, executeWithResult, getCurrentScope, startScope
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
prepareReset, supportsReset
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()
SagaLifecycle
String
denoting the identifier of this Saga.getSagaIdentifier
in interface Saga<T>
getSagaIdentifier
in class SagaLifecycle
String
denoting the identifier of this Sagapublic 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 canHandle(EventMessage<?> event)
EventListener
canHandle
in interface EventListener
event
- The event message to verifytrue
if this listener can handle the event, otherwise false
public final void handle(EventMessage<?> event)
EventListener
handle
in interface EventListener
event
- the event to handlepublic 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 String type()
SagaLifecycle
String
denoting the type of this Saga.type
in class SagaLifecycle
String
denoting the type of this Sagaprotected void doRemoveAssociation(AssociationValue property)
doRemoveAssociation
in class SagaLifecycle
property
- the association value to remove from the saga.Copyright © 2010–2018. All rights reserved.