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,
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 handler can handle the given 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. |
Object |
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.
|
protected String |
type()
Retrieve a
String denoting the type of this Saga. |
associateWith, associateWith, associateWith, describeScope, end, execute, getInstance, removeAssociationWith, removeAssociationWithdescribeCurrentScope, endScope, executeWithResult, getCurrentScope, startScopeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprepareReset, supportsResetgetTargetTypepublic AnnotatedSaga(String sagaId, Set<AssociationValue> associationValues, T annotatedSaga, 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 SagametaModel - The model describing Saga structurepublic String getSagaIdentifier()
SagaLifecycleString denoting the identifier of this Saga.getSagaIdentifier in interface Saga<T>getSagaIdentifier in class SagaLifecycleString denoting the identifier of this Sagapublic AssociationValues getAssociationValues()
SagagetAssociationValues in interface Saga<T>public <R> R invoke(Function<T,R> invocation)
Sagainvocation against the root object of this Saga instance.public void execute(Consumer<T> invocation)
Sagainvocation against the root object of this Saga instance.public final boolean canHandle(EventMessage<?> event)
MessageHandlercanHandle in interface MessageHandler<EventMessage<?>>event - The message to verifytrue if this handler can handle the message, otherwise falsepublic final Object handle(EventMessage<?> event)
EventMessageHandlerhandle in interface EventMessageHandlerhandle in interface MessageHandler<EventMessage<?>>event - the event to handlepublic boolean isActive()
Sagapublic T root()
SagaLifecycle.protected void doEnd()
doEnd in class SagaLifecycleprotected void doAssociateWith(AssociationValue property)
doAssociateWith in class SagaLifecycleproperty - The value to associate this saga with.protected String type()
SagaLifecycleString denoting the type of this Saga.type in class SagaLifecycleString denoting the type of this Sagaprotected void doRemoveAssociation(AssociationValue property)
doRemoveAssociation in class SagaLifecycleproperty - the association value to remove from the saga.Copyright © 2010–2018. All rights reserved.