public abstract class AbstractSagaManager extends Object implements SagaManager, Subscribable
| Constructor and Description |
|---|
AbstractSagaManager(EventBus eventBus,
SagaRepository sagaRepository,
SagaFactory sagaFactory,
Class<? extends Saga>... sagaTypes)
Initializes the SagaManager with the given
eventBus and sagaRepository. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
commit(Saga saga)
Commits the given
saga to the registered repository. |
protected abstract AssociationValue |
extractAssociationValue(Class<? extends Saga> sagaType,
EventMessage event)
Extracts the AssociationValue from the given
event as relevant for a Saga of given
sagaType. |
protected abstract SagaCreationPolicy |
getSagaCreationPolicy(Class<? extends Saga> sagaType,
EventMessage event)
Returns the Saga Creation Policy for a Saga of the given
sagaType and event. |
void |
handle(EventMessage event)
Handles the event by passing it to all Saga instances that have an Association Value found in the given event.
|
void |
setSuppressExceptions(boolean suppressExceptions)
Sets whether or not to suppress any exceptions that are cause by invoking Sagas.
|
void |
setSynchronizeSagaAccess(boolean synchronizeSagaAccess)
Sets whether of not access to Saga's Event Handler should by synchronized.
|
void |
subscribe()
Subscribe the EventListener with the configured EventBus.
|
void |
unsubscribe()
Unsubscribe the EventListener with the configured EventBus.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTargetTypepublic AbstractSagaManager(EventBus eventBus, SagaRepository sagaRepository, SagaFactory sagaFactory, Class<? extends Saga>... sagaTypes)
eventBus and sagaRepository.eventBus - The event bus providing the events to route to sagas.sagaRepository - The repository providing the saga instances.sagaFactory - The factory providing new saga instancessagaTypes - The types of Saga supported by this Saga Managerpublic void handle(EventMessage event)
SagaManagerhandle in interface EventListenerhandle in interface SagaManagerevent - the event to handleprotected abstract SagaCreationPolicy getSagaCreationPolicy(Class<? extends Saga> sagaType, EventMessage event)
sagaType and event.sagaType - The type of Saga to get the creation policy forevent - The Event that is being dispatched to Saga instancesprotected abstract AssociationValue extractAssociationValue(Class<? extends Saga> sagaType, EventMessage event)
event as relevant for a Saga of given
sagaType.sagaType - The type of Saga about to handle the Eventevent - The event containing the association informationprotected void commit(Saga saga)
saga to the registered repository.saga - the Saga to commit.@PreDestroy public void unsubscribe()
unsubscribe in interface Subscribable@PostConstruct public void subscribe()
subscribe in interface Subscribablepublic void setSuppressExceptions(boolean suppressExceptions)
true.suppressExceptions - whether or not to suppress exceptions from Sagas.public void setSynchronizeSagaAccess(boolean synchronizeSagaAccess)
true. Sets
to false only if the Saga managed by this manager are completely thread safe by themselves.synchronizeSagaAccess - whether or not to synchronize access to Saga's event handlers.Copyright © 2010-2013. All Rights Reserved.