org.axonframework.saga.annotation
Class AnnotatedSagaManager

java.lang.Object
  extended by org.axonframework.saga.AbstractReplayAwareSagaManager
      extended by org.axonframework.saga.AbstractSagaManager
          extended by org.axonframework.saga.annotation.AnnotatedSagaManager
All Implemented Interfaces:
Subscribable, EventListener, EventListenerProxy, ReplayAware, SagaManager

public class AnnotatedSagaManager
extends AbstractSagaManager

Implementation of the SagaManager that uses annotations on the Sagas to describe the lifecycle management. Unlike the SimpleSagaManager, this implementation can manage several types of Saga in a single AnnotatedSagaManager.

Since:
0.7
Author:
Allard Buijze

Constructor Summary
AnnotatedSagaManager(SagaRepository sagaRepository, Class<? extends AbstractAnnotatedSaga>... sagaClasses)
          Initialize the AnnotatedSagaManager using given repository to load sagas and supporting given annotated sagaClasses.
AnnotatedSagaManager(SagaRepository sagaRepository, EventBus eventBus, Class<? extends AbstractAnnotatedSaga>... sagaClasses)
          Deprecated. use AnnotatedSagaManager(org.axonframework.saga.SagaRepository, Class[]) instead and register this instance using EventBus.subscribe(org.axonframework.eventhandling.EventListener)
AnnotatedSagaManager(SagaRepository sagaRepository, ParameterResolverFactory parameterResolverFactory, Class<? extends AbstractAnnotatedSaga>... sagaClasses)
          Initialize the AnnotatedSagaManager using given repository to load sagas and supporting given annotated sagaClasses.
AnnotatedSagaManager(SagaRepository sagaRepository, SagaFactory sagaFactory, Class<? extends AbstractAnnotatedSaga>... sagaClasses)
          Initialize the AnnotatedSagaManager using the given resources.
AnnotatedSagaManager(SagaRepository sagaRepository, SagaFactory sagaFactory, EventBus eventBus, Class<? extends AbstractAnnotatedSaga>... sagaClasses)
          Deprecated. use AnnotatedSagaManager(org.axonframework.saga.SagaRepository, org.axonframework.saga.SagaFactory, Class[]) instead and register this instance using EventBus.subscribe(org.axonframework.eventhandling.EventListener)
AnnotatedSagaManager(SagaRepository sagaRepository, SagaFactory sagaFactory, ParameterResolverFactory parameterResolverFactory, Class<? extends AbstractAnnotatedSaga>... sagaClasses)
          Initialize the AnnotatedSagaManager using the given resources.
 
Method Summary
protected  Set<AssociationValue> extractAssociationValues(Class<? extends Saga> sagaType, EventMessage event)
          Extracts the AssociationValues from the given event as relevant for a Saga of given sagaType.
protected  SagaInitializationPolicy getSagaCreationPolicy(Class<? extends Saga> sagaType, 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  void preProcessSaga(Saga saga)
          Perform pre-processing of sagas that have been newly created or have been loaded from the repository.
 
Methods inherited from class org.axonframework.saga.AbstractSagaManager
commit, getManagedSagaTypes, handle, 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

AnnotatedSagaManager

@Deprecated
public AnnotatedSagaManager(SagaRepository sagaRepository,
                                       EventBus eventBus,
                                       Class<? extends AbstractAnnotatedSaga>... sagaClasses)
Deprecated. use AnnotatedSagaManager(org.axonframework.saga.SagaRepository, Class[]) instead and register this instance using EventBus.subscribe(org.axonframework.eventhandling.EventListener)

Initialize the AnnotatedSagaManager using the given resources, and using a GenericSagaFactory.

Parameters:
sagaRepository - The repository providing access to the Saga instances
eventBus - The event bus publishing the events
sagaClasses - The types of Saga that this instance should manage

AnnotatedSagaManager

@Deprecated
public AnnotatedSagaManager(SagaRepository sagaRepository,
                                       SagaFactory sagaFactory,
                                       EventBus eventBus,
                                       Class<? extends AbstractAnnotatedSaga>... sagaClasses)
Deprecated. use AnnotatedSagaManager(org.axonframework.saga.SagaRepository, org.axonframework.saga.SagaFactory, Class[]) instead and register this instance using EventBus.subscribe(org.axonframework.eventhandling.EventListener)

Initialize the AnnotatedSagaManager using the given resources.

Parameters:
sagaRepository - The repository providing access to the Saga instances
sagaFactory - The factory creating new instances of a Saga
eventBus - The event bus publishing the events
sagaClasses - The types of Saga that this instance should manage

AnnotatedSagaManager

public AnnotatedSagaManager(SagaRepository sagaRepository,
                            Class<? extends AbstractAnnotatedSaga>... sagaClasses)
Initialize the AnnotatedSagaManager using given repository to load sagas and supporting given annotated sagaClasses.

Parameters:
sagaRepository - The repository providing access to the Saga instances
sagaClasses - The types of Saga that this instance should manage

AnnotatedSagaManager

public AnnotatedSagaManager(SagaRepository sagaRepository,
                            ParameterResolverFactory parameterResolverFactory,
                            Class<? extends AbstractAnnotatedSaga>... sagaClasses)
Initialize the AnnotatedSagaManager using given repository to load sagas and supporting given annotated sagaClasses.

Parameters:
sagaRepository - The repository providing access to the Saga instances
parameterResolverFactory - The parameterResolverFactory to resolve parameters with for the saga instance's handler methods
sagaClasses - The types of Saga that this instance should manage

AnnotatedSagaManager

public AnnotatedSagaManager(SagaRepository sagaRepository,
                            SagaFactory sagaFactory,
                            Class<? extends AbstractAnnotatedSaga>... sagaClasses)
Initialize the AnnotatedSagaManager using the given resources.

Parameters:
sagaRepository - The repository providing access to the Saga instances
sagaFactory - The factory creating new instances of a Saga
sagaClasses - The types of Saga that this instance should manage

AnnotatedSagaManager

public AnnotatedSagaManager(SagaRepository sagaRepository,
                            SagaFactory sagaFactory,
                            ParameterResolverFactory parameterResolverFactory,
                            Class<? extends AbstractAnnotatedSaga>... sagaClasses)
Initialize the AnnotatedSagaManager using the given resources.

Parameters:
sagaRepository - The repository providing access to the Saga instances
sagaFactory - The factory creating new instances of a Saga
parameterResolverFactory - The parameterResolverFactory to resolve parameters with for the saga instance's handler methods
sagaClasses - The types of Saga that this instance should manage
Method Detail

getSagaCreationPolicy

protected SagaInitializationPolicy getSagaCreationPolicy(Class<? extends Saga> sagaType,
                                                         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:
sagaType - 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> sagaType,
                                                         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:
sagaType - 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

preProcessSaga

protected void preProcessSaga(Saga saga)
Description copied from class: AbstractSagaManager
Perform pre-processing of sagas that have been newly created or have been loaded from the repository. This method is invoked prior to invocation of the saga instance itself.

Overrides:
preProcessSaga in class AbstractSagaManager
Parameters:
saga - The saga instance for pre-processing

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.