org.axonframework.saga
Class SimpleSagaManager

java.lang.Object
  extended by org.axonframework.saga.AbstractSagaManager
      extended by org.axonframework.saga.SimpleSagaManager
All Implemented Interfaces:
Subscribable, EventListener, EventListenerProxy, SagaManager

public class SimpleSagaManager
extends AbstractSagaManager

Simple SagaManager implementation. This implementation requires the Event that should cause new Saga's to be created, to be registered using setEventsToAlwaysCreateNewSagasFor(java.util.List) and setEventsToOptionallyCreateNewSagasFor(java.util.List).

Since:
0.7
Author:
Allard Buijze

Constructor Summary
SimpleSagaManager(Class<? extends Saga> sagaType, SagaRepository sagaRepository, AssociationValueResolver associationValueResolver, EventBus eventBus)
          Initialize a SimpleSagaManager backed by the given resources, using a GenericSagaFactory.
SimpleSagaManager(Class<? extends Saga> sagaType, SagaRepository sagaRepository, AssociationValueResolver associationValueResolver, SagaFactory sagaFactory, EventBus eventBus)
          Initialize a SimpleSagaManager backed by the given resources.
 
Method Summary
protected  AssociationValue extractAssociationValue(Class<? extends Saga> type, EventMessage event)
          Extracts the AssociationValue from the given event as relevant for a Saga of given sagaType.
protected  SagaCreationPolicy getSagaCreationPolicy(Class<? extends Saga> type, EventMessage event)
          Returns the Saga Creation Policy for a Saga of the given sagaType and event.
 Class<?> getTargetType()
          Returns the instance type that this proxy delegates all event handling to.
 void setEventsToAlwaysCreateNewSagasFor(List<Class<?>> events)
          Sets the types of Events that should cause the creation of a new Saga instance, even if one already exists.
 void setEventsToOptionallyCreateNewSagasFor(List<Class<?>> events)
          Sets the types of Events that should cause the creation of a new Saga instance if one does not already exist.
 
Methods inherited from class org.axonframework.saga.AbstractSagaManager
commit, handle, setSuppressExceptions, setSynchronizeSagaAccess, subscribe, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSagaManager

public SimpleSagaManager(Class<? extends Saga> sagaType,
                         SagaRepository sagaRepository,
                         AssociationValueResolver associationValueResolver,
                         EventBus eventBus)
Initialize a SimpleSagaManager backed by the given resources, using a GenericSagaFactory.

Parameters:
sagaType - The type of Saga managed by this SagaManager
sagaRepository - The repository providing access to Saga instances
associationValueResolver - The instance providing AssociationValues for incoming Events
eventBus - The event bus that the manager should register to

SimpleSagaManager

public SimpleSagaManager(Class<? extends Saga> sagaType,
                         SagaRepository sagaRepository,
                         AssociationValueResolver associationValueResolver,
                         SagaFactory sagaFactory,
                         EventBus eventBus)
Initialize a SimpleSagaManager backed by the given resources.

Parameters:
sagaType - The type of Saga managed by this SagaManager
sagaRepository - The repository providing access to Saga instances
associationValueResolver - The instance providing AssociationValues for incoming Events
sagaFactory - The factory creating new Saga instances
eventBus - The event bus that the manager should register to
Method Detail

getSagaCreationPolicy

protected SagaCreationPolicy getSagaCreationPolicy(Class<? extends Saga> type,
                                                   EventMessage event)
Description copied from class: AbstractSagaManager
Returns the Saga Creation Policy for a Saga of the given sagaType and event.

Specified by:
getSagaCreationPolicy in class AbstractSagaManager
Parameters:
type - The type of Saga to get the creation policy for
event - The Event that is being dispatched to Saga instances
Returns:
the creation policy for the Saga

extractAssociationValue

protected AssociationValue extractAssociationValue(Class<? extends Saga> type,
                                                   EventMessage event)
Description copied from class: AbstractSagaManager
Extracts the AssociationValue from the given event as relevant for a Saga of given sagaType.

Specified by:
extractAssociationValue in class AbstractSagaManager
Parameters:
type - The type of Saga about to handle the Event
event - The event containing the association information
Returns:
the AssociationValue indicating which Sagas should handle given event

setEventsToAlwaysCreateNewSagasFor

public void setEventsToAlwaysCreateNewSagasFor(List<Class<?>> events)
Sets the types of Events that should cause the creation of a new Saga instance, even if one already exists.

Parameters:
events - the types of Events that should cause the creation of a new Saga instance, even if one already exists

setEventsToOptionallyCreateNewSagasFor

public void setEventsToOptionallyCreateNewSagasFor(List<Class<?>> events)
Sets the types of Events that should cause the creation of a new Saga instance if one does not already exist.

Parameters:
events - the types of Events that should cause the creation of a new Saga instance if one does not already exist

getTargetType

public Class<?> getTargetType()
Description copied from interface: EventListenerProxy
Returns the instance type that this proxy delegates all event handling to.

Returns:
the instance type that this proxy delegates all event handling to


Copyright © 2010-2012. All Rights Reserved.