Class LockingSagaRepository<T>
java.lang.Object
org.axonframework.modelling.saga.repository.LockingSagaRepository<T>
- All Implemented Interfaces:
SagaRepository<T>
- Direct Known Subclasses:
AnnotatedSagaRepository
Abstract implementation of a saga repository that locks access to a saga while the saga is being operated on.
- Since:
- 3.0
- Author:
- Rene de Waele
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstract Builder class to instantiateLockingSagaRepositoryimplementations. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aLockingSagaRepositorybased on the fields contained in theLockingSagaRepository.Builder. -
Method Summary
Modifier and TypeMethodDescriptioncreateInstance(String sagaIdentifier, Supplier<T> factoryMethod) Creates a new Saga instance.doCreateInstance(String sagaIdentifier, Supplier<T> factoryMethod) Creates a new Saga instance.Loads a known Saga instance by its unique identifier.Loads a known Saga instance by its unique identifier.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.modelling.saga.SagaRepository
find
-
Constructor Details
-
LockingSagaRepository
Instantiate aLockingSagaRepositorybased on the fields contained in theLockingSagaRepository.Builder.Will assert that the
LockFactoryis notnull. Will throw anAxonConfigurationExceptionif it is.- Parameters:
builder- theLockingSagaRepository.Builderused to instantiate aLockingSagaRepositoryinstance
-
-
Method Details
-
load
Loads a known Saga instance by its unique identifier. Due to the concurrent nature of Sagas, it is not unlikely for a Saga to have ceased to exist after it has been found based on associations. Therefore, a repository should returnnullin case a Saga doesn't exists, as opposed to throwing an exception.This implementation locks access to sagas with the given
sagaIdentifierand releases the lock in the clean-up phase of the currentUnitOfWork.- Specified by:
loadin interfaceSagaRepository<T>- Parameters:
sagaIdentifier- The unique identifier of the Saga to load- Returns:
- The Saga instance, or
nullif no such saga exists
-
createInstance
Creates a new Saga instance. The returned Saga will delegate event handling to the instance supplied by the givenfactoryMethod.This implementation locks access to sagas with the given
sagaIdentifierand releases the lock in the clean-up phase of the currentUnitOfWork.- Specified by:
createInstancein interfaceSagaRepository<T>- Parameters:
sagaIdentifier- the identifier to use for the new saga instancefactoryMethod- Used to create a new Saga delegate- Returns:
- a new Saga instance wrapping an instance of type
T
-
doLoad
Loads a known Saga instance by its unique identifier. Due to the concurrent nature of Sagas, it is not unlikely for a Saga to have ceased to exist after it has been found based on associations. Therefore, a repository should returnnullin case a Saga doesn't exists, as opposed to throwing an exception.- Parameters:
sagaIdentifier- The unique identifier of the Saga to load- Returns:
- The Saga instance, or
nullif no such saga exists
-
doCreateInstance
Creates a new Saga instance. The returned Saga will delegate event handling to the instance supplied by the givenfactoryMethod.- Parameters:
sagaIdentifier- the identifier to use for the new saga instancefactoryMethod- Used to create a new Saga delegate- Returns:
- a new Saga instance wrapping an instance of type
T
-