Class AnnotatedSagaManager<T>
- Type Parameters:
T- The type of Saga managed by this instance
- All Implemented Interfaces:
EventHandlerInvoker,ScopeAware
- Since:
- 0.7
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aAnnotatedSagaManager. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aAnnotatedSagaManagerbased on the fields contained in theAnnotatedSagaManager.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> AnnotatedSagaManager.Builder<T> builder()Instantiate a Builder to be able to create aAnnotatedSagaManager.booleancanHandle(EventMessage<?> eventMessage, Segment segment) Check whether or not this invoker has handlers that can handle the giveneventMessagefor a givensegment.protected Set<AssociationValue> extractAssociationValues(EventMessage<?> event) Extracts the AssociationValues from the giveneventas relevant for a Saga of givensagaType.protected SagaInitializationPolicygetSagaCreationPolicy(EventMessage<?> event) Returns the Saga Initialization Policy for a Saga of the givensagaTypeandevent.Methods inherited from class org.axonframework.modelling.saga.AbstractSagaManager
canResolve, createSagaIdentifier, getSagaType, handle, matchesSegment, performReset, performReset, send, supportsResetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.eventhandling.EventHandlerInvoker
canHandleType, segmentReleased
-
Constructor Details
-
AnnotatedSagaManager
Instantiate aAnnotatedSagaManagerbased on the fields contained in theAnnotatedSagaManager.Builder.The
sagaFactoryis defaulted to asagaType.newInstance()call throwing aSagaInstantiationExceptionif it fails, theSagaManagerSpanFactorydefaults to aDefaultSagaManagerSpanFactorybacked by aNoOpSpanFactory, and theListenerInvocationErrorHandleris defaulted to aLoggingErrorHandler. TheSagaRepositoryandsagaTypeare hard requirements and as such should be provided.Will assert that the
SagaRepository,sagaType,sagaFactoryandListenerInvocationErrorHandlerare notnull, and will throw anAxonConfigurationExceptionif any of them isnull. Additionally, the provided Builder's goal is to either build aSagaModelspecifying genericTas the Saga type to be stored or derive it based on the givensagaType. All Sagas managed by this Saga manager must beinstanceOfthis Saga type.- Parameters:
builder- theAnnotatedSagaManager.Builderused to instantiate aAnnotatedSagaManagerinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aAnnotatedSagaManager.The
sagaFactoryis defaulted to asagaType.newInstance()call throwing aSagaInstantiationExceptionif it fails, theListenerInvocationErrorHandleris defaulted to aLoggingErrorHandlerand theSagaManagerSpanFactoryis defaulted to aDefaultSagaManagerSpanFactorybacked by aNoOpSpanFactory.This Builder either allows directly setting a
SagaModelof generic typeT, or it will generate one based of the requiredsagaTypefield of typeClass. Thus, either the SagaModel or thesagaTypeshould be provided. All Sagas managed by this instances must beinstanceOfthis saga type. Additionally, theSagaRepositoryandsagaTypeare hard requirements and as such should be provided.- Type Parameters:
T- a generic specifying the Saga type managed by thisAbstractSagaManagerimplementation- Returns:
- a Builder to be able to create a
AnnotatedSagaManager
-
canHandle
Description copied from interface:EventHandlerInvokerCheck whether or not this invoker has handlers that can handle the giveneventMessagefor a givensegment.- Parameters:
eventMessage- The message to be processedsegment- The segment for which the event handler should be invoked- Returns:
trueif the invoker has one or more handlers that can handle the given message,falseotherwise
-
getSagaCreationPolicy
Description copied from class:AbstractSagaManagerReturns the Saga Initialization Policy for a Saga of the givensagaTypeandevent. This policy provides the conditions to create new Saga instance, as well as the initial association of that saga.- Specified by:
getSagaCreationPolicyin classAbstractSagaManager<T>- Parameters:
event- The Event that is being dispatched to Saga instances- Returns:
- the initialization policy for the Saga
-
extractAssociationValues
Description copied from class:AbstractSagaManagerExtracts the AssociationValues from the giveneventas relevant for a Saga of givensagaType. A single event may be associated with multiple values.- Specified by:
extractAssociationValuesin classAbstractSagaManager<T>- Parameters:
event- The event containing the association information- Returns:
- the AssociationValues indicating which Sagas should handle given event
-