org.axonframework.saga
Class SimpleSagaManager

java.lang.Object
  extended by org.axonframework.saga.AbstractReplayAwareSagaManager
      extended by org.axonframework.saga.AbstractSagaManager
          extended by org.axonframework.saga.SimpleSagaManager
All Implemented Interfaces:
Subscribable, EventListener, EventListenerProxy, ReplayAware, 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)
          Initialize a SimpleSagaManager backed by the given resources, using a GenericSagaFactory.
SimpleSagaManager(Class<? extends Saga> sagaType, SagaRepository sagaRepository, AssociationValueResolver associationValueResolver, EventBus eventBus)
          Deprecated. use SimpleSagaManager(Class, SagaRepository, AssociationValueResolver) and register using EventBus.subscribe(org.axonframework.eventhandling.EventListener)
SimpleSagaManager(Class<? extends Saga> sagaType, SagaRepository sagaRepository, AssociationValueResolver associationValueResolver, SagaFactory sagaFactory)
          Initialize a SimpleSagaManager backed by the given resources.
SimpleSagaManager(Class<? extends Saga> sagaType, SagaRepository sagaRepository, AssociationValueResolver associationValueResolver, SagaFactory sagaFactory, EventBus eventBus)
          Deprecated. use SimpleSagaManager(Class, SagaRepository, AssociationValueResolver, SagaFactory) and register using EventBus.subscribe(org.axonframework.eventhandling.EventListener)
 
Method Summary
protected  Set<AssociationValue> extractAssociationValues(Class<? extends Saga> type, EventMessage event)
          Extracts the AssociationValues from the given event as relevant for a Saga of given sagaType.
protected  SagaInitializationPolicy getSagaCreationPolicy(Class<? extends Saga> type, EventMessage event)
          Returns the Saga Initialization Policy for a Saga of the given sagaType and event.
 Class<?> getTargetType()
          Returns the instance type that this proxy delegates all event handling to.
protected  AssociationValue initialAssociationValue(EventMessage event)
          Returns the association value to assign to a Saga when the given event triggers the creation of a new instance.
 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, getManagedSagaTypes, handle, preProcessSaga, setCorrelationDataProvider, setCorrelationDataProviders, setSuppressExceptions, setSynchronizeSagaAccess, subscribe, unsubscribe
 
Methods inherited from class org.axonframework.saga.AbstractReplayAwareSagaManager
afterReplay, beforeReplay, onReplayFailed, setReplayable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSagaManager

@Deprecated
public SimpleSagaManager(Class<? extends Saga> sagaType,
                                    SagaRepository sagaRepository,
                                    AssociationValueResolver associationValueResolver,
                                    EventBus eventBus)
Deprecated. use SimpleSagaManager(Class, SagaRepository, AssociationValueResolver) and register using EventBus.subscribe(org.axonframework.eventhandling.EventListener)

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

@Deprecated
public SimpleSagaManager(Class<? extends Saga> sagaType,
                                    SagaRepository sagaRepository,
                                    AssociationValueResolver associationValueResolver,
                                    SagaFactory sagaFactory,
                                    EventBus eventBus)
Deprecated. use SimpleSagaManager(Class, SagaRepository, AssociationValueResolver, SagaFactory) and register using EventBus.subscribe(org.axonframework.eventhandling.EventListener)

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

SimpleSagaManager

public SimpleSagaManager(Class<? extends Saga> sagaType,
                         SagaRepository sagaRepository,
                         AssociationValueResolver associationValueResolver)
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

SimpleSagaManager

public SimpleSagaManager(Class<? extends Saga> sagaType,
                         SagaRepository sagaRepository,
                         AssociationValueResolver associationValueResolver,
                         SagaFactory sagaFactory)
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
Method Detail

getSagaCreationPolicy

protected SagaInitializationPolicy getSagaCreationPolicy(Class<? extends Saga> type,
                                                         EventMessage event)
Description copied from class: AbstractSagaManager
Returns the Saga Initialization Policy for a Saga of the given sagaType and event. This policy provides the conditions to create new Saga instance, as well as the initial association of that saga.

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 initialization policy for the Saga

extractAssociationValues

protected Set<AssociationValue> extractAssociationValues(Class<? extends Saga> type,
                                                         EventMessage event)
Description copied from class: AbstractSagaManager
Extracts the AssociationValues from the given event as relevant for a Saga of given sagaType. A single event may be associated with multiple values.

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

initialAssociationValue

protected AssociationValue initialAssociationValue(EventMessage event)
Returns the association value to assign to a Saga when the given event triggers the creation of a new instance. If there are no creation handlers for the given event, null is returned.

Parameters:
event - The event to resolve the initial association for
Returns:
The association value to assign, or null

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-2016. All Rights Reserved.