|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.saga.repository.CachingSagaRepository
public class CachingSagaRepository
Saga Repository implementation that adds caching behavior to the repository it wraps. Both associations and sagas are cached, making loading them faster. Commits and adds are always delegated to the wrapped repository. Loads are only delegated if the cache does not contain the necessary entries.
Updating associations involves a read and a write, which are performed atomically. Therefore, it is unsafe to add or remove specific associations outside of this instance. Obviously, clearing and evictions are safe.
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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 in| Method Detail |
|---|
public Set<String> find(Class<? extends Saga> type,
AssociationValue associationValue)
SagaRepositorytype that have been associated with the given
associationValue.
Returned Sagas must be committed after processing.
find in interface SagaRepositorytype - The type of Saga to returnassociationValue - The value that the returned Sagas must be associated with
null.public Saga load(String sagaIdentifier)
SagaRepositorycommitted
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 SagaRepositorysagaIdentifier - The unique identifier of the Saga to load
null if no such saga existspublic void commit(Saga saga)
SagaRepositorySaga.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 SagaRepositorysaga - The Saga instance to commitpublic void add(Saga saga)
SagaRepositorySaga.isActive() returns
false), it is not stored.
add in interface SagaRepositorysaga - The Saga instances to add.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||