T- generic type specifying the Saga type stored by this
public class AnnotatedSagaRepository<T> extends LockingSagaRepository<T>
SagaRepositoryimplementation extending from the
LockingSagaRepositorydealing with annotated Sagas. Will take care of the uniqueness of
Sagainstances in the JVM. That means it will prevent multiple instances of the same conceptual Saga (i.e. with same identifier) to exist within the JVM.
|Modifier and Type||Class and Description|
Builder class to instantiate a
|Modifier||Constructor and Description|
|Modifier and Type||Method and Description|
Instantiate a Builder to be able to create an
Commits the given modified
Remove the given saga as well as all known association values pointing to it from the repository.
Creates a new Saga instance.
Loads a known Saga instance by its unique identifier.
Loads the saga with given
Find saga instances of the given
Stores a newly created Saga instance.
Returns a set of identifiers of sagas that may have changed in the context of the given
Update a stored Saga, by replacing it with the given
protected AnnotatedSagaRepository(AnnotatedSagaRepository.Builder<T> builder)
AnnotatedSagaRepositorybased on the fields contained in the
Will assert that the
ResourceInjector are not
will throw an
AxonConfigurationException if any of them is
null. Additionally, the provided
builder's goal is to either build a
SagaModel specifying generic
T as the Saga type to be stored
or derive it based on the given
sagaType. The same argument applies to the
Sagas in this repository must be
instanceOf this saga type.
public static <T> AnnotatedSagaRepository.Builder<T> builder()
ResourceInjector is defaulted to a
NoResourceInjector. This Builder either allows directly
SagaModel of generic type
T, or it will generate it based of the required
sagaType field of type
Class. Same for the
either the SagaModel or the
sagaType should be provided. All Saga in this repository must be
instanceOf this saga type. Additionally, the
SagaStore are hard
requirements and as such should be provided.
public AnnotatedSaga<T> doLoad(String sagaIdentifier)
nullin case a Saga doesn't exists, as opposed to throwing an exception.
public AnnotatedSaga<T> doCreateInstance(String sagaIdentifier, Supplier<T> sagaFactory)
protected Set<String> unsavedSagaResource(UnitOfWork<?> unitOfWork)
unitOfWorkand have not been saved yet.
unitOfWork- the unit of work to inspect for unsaved sagas
protected void commit(AnnotatedSaga<T> saga)
sagato the underlying saga store. If the saga is not active anymore it will be deleted. Otherwise the stored saga and its associations will be updated.
saga- the saga to commit to the store
public Set<String> find(AssociationValue associationValue)
typethat have been associated with the given
associationValue- The value that the returned Sagas must be associated with
protected void deleteSaga(AnnotatedSaga<T> saga)
saga- The saga instance to remove from the repository
protected void updateSaga(AnnotatedSaga<T> saga)
saga- The saga that has been modified and needs to be updated in the storage
protected void storeSaga(AnnotatedSaga<T> saga)
saga- The newly created Saga instance to store.
protected AnnotatedSaga<T> doLoadSaga(String sagaIdentifier)
sagaIdentifierfrom the underlying saga store and returns it as a
AnnotatedSaga. Resources of the saga will be injected using the
ResourceInjectorconfigured with the repository.
sagaIdentifier- the identifier of the saga to load
Copyright © 2010–2023. All rights reserved.