public abstract class AbstractSagaManager<T> extends Object implements EventHandlerInvoker, ScopeAware
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractSagaManager.Builder<T>
Abstract Builder class to instantiate
AbstractSagaManager implementations. |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSagaManager(AbstractSagaManager.Builder<T> builder)
Instantiate a
AbstractSagaManager based on the fields contained in the AbstractSagaManager.Builder. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canResolve(ScopeDescriptor scopeDescription)
Check whether this implementation can resolve a
Scope object based on the provided scopeDescription. |
protected String |
createSagaIdentifier(Segment segment)
Creates a Saga identifier that will cause a Saga instance to be considered part of the given
segment. |
protected abstract Set<AssociationValue> |
extractAssociationValues(EventMessage<?> event)
Extracts the AssociationValues from the given
event as relevant for a Saga of given
sagaType. |
protected abstract SagaInitializationPolicy |
getSagaCreationPolicy(EventMessage<?> event)
Returns the Saga Initialization Policy for a Saga of the given
sagaType and event. |
Class<T> |
getSagaType()
Returns the class of Saga managed by this SagaManager
|
void |
handle(EventMessage<?> event,
Segment segment)
Handle the given
message for the given segment. |
protected boolean |
matchesSegment(Segment segment,
String sagaId)
Checks whether the given
sagaId matches with the given segment. |
void |
performReset()
Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
|
void |
performReset(Object resetContext)
Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
|
void |
send(Message<?> message,
ScopeDescriptor scopeDescription)
|
boolean |
supportsReset()
Indicates whether the handlers managed by this invoker support a reset.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanHandle, canHandleTypeprotected AbstractSagaManager(AbstractSagaManager.Builder<T> builder)
AbstractSagaManager based on the fields contained in the AbstractSagaManager.Builder.
Will assert that the sagaType, sagaFactory, SagaRepository and
ListenerInvocationErrorHandler are not null, and will throw an AxonConfigurationException
if any of them is null.
builder - the AbstractSagaManager.Builder used to instantiate a AbstractSagaManager instancepublic void handle(EventMessage<?> event, Segment segment) throws Exception
EventHandlerInvokermessage for the given segment.
Callers are recommended to invoke EventHandlerInvoker.canHandle(EventMessage, Segment) prior to invocation, but aren't
required to do so. Implementations must ensure to take the given segment into account when processing messages.
handle in interface EventHandlerInvokerevent - The message to handlesegment - The segment for which to handle the messageException - when an exception occurs while handling the messageprotected String createSagaIdentifier(Segment segment)
segment.segment - The segment the identifier must match withIdentifierFactory, until
one is returned that matches the given segment. See matchesSegment(Segment, String).protected boolean matchesSegment(Segment segment, String sagaId)
sagaId matches with the given segment.
For any complete set of segments, exactly one segment matches with any value.
segment - The segment to validate the identifier forsagaId - The identifier to testtrue if the identifier matches the segment, otherwise falseSegment.matches(Object) to match against the Saga identifierprotected abstract SagaInitializationPolicy getSagaCreationPolicy(EventMessage<?> event)
sagaType and event. This
policy provides the conditions to create new Saga instance, as well as the initial association of that saga.event - The Event that is being dispatched to Saga instancesprotected abstract Set<AssociationValue> extractAssociationValues(EventMessage<?> event)
event as relevant for a Saga of given
sagaType. A single event may be associated with multiple values.event - The event containing the association informationpublic Class<T> getSagaType()
public boolean supportsReset()
EventHandlerInvokersupportsReset in interface EventHandlerInvokertrue if a reset is supported, otherwise falsepublic void performReset()
EventHandlerInvokerperformReset in interface EventHandlerInvokerpublic void performReset(Object resetContext)
EventHandlerInvokerperformReset in interface EventHandlerInvokerresetContext - a R used to support the reset operationpublic void send(Message<?> message, ScopeDescriptor scopeDescription) throws Exception
ScopeAwaresend in interface ScopeAwaremessage - a Message to be send to a ScopescopeDescription - a D extending ScopeDescriptor, describing the Scope to send the
given message toException - if sending the message failed. Might occur if the message handling process throws an
exceptionpublic boolean canResolve(ScopeDescriptor scopeDescription)
ScopeAwareScope object based on the provided scopeDescription. Will return true in case it should be able to resolve the Scope and false if
it cannot.canResolve in interface ScopeAwarescopeDescription - a ScopeDescriptor describing the Scope to be resolvedtrue in case it should be able to resolve the Scope and false if it cannotCopyright © 2010–2020. All rights reserved.