public class CachingSagaRepository extends Object implements SagaRepository
Constructor and Description |
---|
CachingSagaRepository(SagaRepository delegate,
Cache associationsCache,
Cache sagaCache)
Initializes an instance delegating to the given
delegate , storing associations in the given
associationsCache and Saga instances in the given sagaCache . |
Modifier and Type | Method and Description |
---|---|
void |
add(Saga saga)
Registers a newly created Saga with the Repository.
|
void |
commit(Saga saga)
Commits the changes made to the Saga instance.
|
Set<String> |
find(Class<? extends Saga> type,
AssociationValue associationValue)
Find saga instances of the given
type that have been associated with the given
associationValue . |
Saga |
load(String sagaIdentifier)
Loads a known Saga instance by its unique identifier.
|
public CachingSagaRepository(SagaRepository delegate, Cache associationsCache, Cache sagaCache)
delegate
, storing associations in the given
associationsCache
and Saga instances in the given sagaCache
.delegate
- The repository instance providing access to (persisted) entriesassociationsCache
- The cache to store association information issagaCache
- The cache to store Saga instances inpublic Set<String> find(Class<? extends Saga> type, AssociationValue associationValue)
SagaRepository
type
that have been associated with the given
associationValue
.
Returned Sagas must be committed
after processing.find
in interface SagaRepository
type
- The type of Saga to returnassociationValue
- The value that the returned Sagas must be associated withnull
.public Saga load(String sagaIdentifier)
SagaRepository
committed
after processing.
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 return null
in case a Saga doesn't
exists, as opposed to throwing an exception.load
in interface SagaRepository
sagaIdentifier
- The unique identifier of the Saga to loadnull
if no such saga existspublic void commit(Saga saga)
SagaRepository
Saga.isActive()
returns
false
), the repository should delete the saga from underlying storage and remove all stored association
values associated with that Saga.
Implementations *may* (temporarily) return a cached version of the Saga, which is marked inactive.commit
in interface SagaRepository
saga
- The Saga instance to commitpublic void add(Saga saga)
SagaRepository
Saga.isActive()
returns
false
), it is not stored.add
in interface SagaRepository
saga
- The Saga instances to add.Copyright © 2010-2014. All Rights Reserved.