org.axonframework.saga
Interface SagaRepository

All Known Implementing Classes:
AbstractSagaRepository, InMemorySagaRepository, JpaSagaRepository

public interface SagaRepository

Interface towards the storage mechanism of Saga instances. Saga Repositories can find sagas either through the values they have been associated with (see AssociationValue) or via their unique identifier.

Since:
0.7
Author:
Allard Buijze

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.
<T extends Saga>
Set<T>
find(Class<T> type, Set<AssociationValue> associationValue)
          Find saga instances of the given type that have been associated with the given associationValue.
<T extends Saga>
T
load(Class<T> type, String sagaIdentifier)
          Loads a known Saga instance by its unique identifier.
 

Method Detail

find

<T extends Saga> Set<T> find(Class<T> type,
                             Set<AssociationValue> associationValue)
Find saga instances of the given type that have been associated with the given associationValue.

Returned Sagas must be committed after processing.

Type Parameters:
T - The type of Saga to return
Parameters:
type - The type of Saga to return
associationValue - The value that the returned Sagas must be associated with
Returns:
A Set containing the found Saga instances. If none are found, an empty Set is returned. Will never return null.

load

<T extends Saga> T load(Class<T> type,
                        String sagaIdentifier)
                    throws NoSuchSagaException
Loads a known Saga instance by its unique identifier. Returned Sagas must be committed after processing.

Type Parameters:
T - The expected type of Saga
Parameters:
type - The expected type of Saga
sagaIdentifier - The unique identifier of the Saga to load
Returns:
The Saga instance
Throws:
NoSuchSagaException - if no Saga with given identifier can be found

commit

void commit(Saga saga)
Commits the changes made to the Saga instance. At this point, the repository may release any resources kept for this saga.

Parameters:
saga - The Saga instance to commit

add

void add(Saga saga)
Registers a newly created Saga with the Repository. Once a Saga instance has been added, it can be found using its association values or its unique identifier.

Parameters:
saga - The Saga instances to add.


Copyright © 2011. All Rights Reserved.