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, removeAssociationWith
describeCurrentScope, endScope, executeWithResult, getCurrentScope, startScope
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
prepareReset, supportsReset
getTargetType
public 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()
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)
MessageHandler
canHandle
in interface MessageHandler<EventMessage<?>>
event
- The message to verifytrue
if this handler can handle the message, otherwise false
public final Object handle(EventMessage<?> event)
EventMessageHandler
handle
in interface EventMessageHandler
handle
in interface MessageHandler<EventMessage<?>>
event
- the event to handlepublic boolean isActive()
Saga
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.