org.axonframework.saga.repository.inmemory
Class InMemorySagaRepository

java.lang.Object
  extended by org.axonframework.saga.repository.inmemory.InMemorySagaRepository
All Implemented Interfaces:
SagaRepository

public class InMemorySagaRepository
extends Object
implements SagaRepository

SagaRepository implementation that stores all Saga instances in memory.

Since:
0.7
Author:
Allard Buijze

Constructor Summary
InMemorySagaRepository()
           
 
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> associationValues)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InMemorySagaRepository

public InMemorySagaRepository()
Method Detail

find

public <T extends Saga> Set<T> find(Class<T> type,
                                    Set<AssociationValue> associationValues)
Description copied from interface: SagaRepository
Find saga instances of the given type that have been associated with the given associationValue.

Returned Sagas must be committed after processing.

Specified by:
find in interface SagaRepository
Type Parameters:
T - The type of Saga to return
Parameters:
type - The type of Saga to return
associationValues - 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

public <T extends Saga> T load(Class<T> type,
                               String sagaIdentifier)
Description copied from interface: SagaRepository
Loads a known Saga instance by its unique identifier. Returned Sagas must be committed after processing.

Specified by:
load in interface SagaRepository
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

commit

public void commit(Saga saga)
Description copied from interface: SagaRepository
Commits the changes made to the Saga instance. At this point, the repository may release any resources kept for this saga.

Specified by:
commit in interface SagaRepository
Parameters:
saga - The Saga instance to commit

add

public void add(Saga saga)
Description copied from interface: SagaRepository
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.

Specified by:
add in interface SagaRepository
Parameters:
saga - The Saga instances to add.


Copyright © 2011. All Rights Reserved.