|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.unitofwork.AbstractUnitOfWork
org.axonframework.unitofwork.DefaultUnitOfWork
public class DefaultUnitOfWork
Implementation of the UnitOfWork that buffers all published events until it is committed. Aggregates that have not been explicitly save in their aggregates will be saved when the UnitOfWork commits.
This implementation requires a mechanism that explicitly commits or rolls back.
| Constructor Summary | |
|---|---|
DefaultUnitOfWork()
|
|
| Method Summary | ||
|---|---|---|
protected void |
doCommit()
Executes the logic required to commit this unit of work. |
|
protected void |
doRollback(Throwable cause)
Executes the logic required to commit this unit of work. |
|
protected void |
notifyListenersAfterCommit()
Send a UnitOfWorkListener.afterCommit() notification to all registered listeners. |
|
protected void |
notifyListenersCleanup()
Send a UnitOfWorkListener.onCleanup() notification to all registered
listeners. |
|
protected void |
notifyListenersPrepareCommit()
Send a UnitOfWorkListener.onPrepareCommit(java.util.Set, java.util.List)
notification to all registered listeners. |
|
protected void |
notifyListenersRollback(Throwable cause)
Send a UnitOfWorkListener.onRollback(Throwable) notification to all registered listeners. |
|
void |
publishEvent(Event event,
EventBus eventBus)
Request to publish the given event on the given eventBus. |
|
protected void |
publishEvents()
Publishes all registered events to their respective event bus. |
|
|
registerAggregate(T aggregate,
SaveAggregateCallback<T> callback)
Register an aggregate with this UnitOfWork. |
|
void |
registerListener(UnitOfWorkListener listener)
Register a listener that listens to state changes in this UnitOfWork. |
|
protected void |
saveAggregates()
Saves all registered aggregates by calling their respective callbacks. |
|
static UnitOfWork |
startAndGet()
Starts a new DefaultUnitOfWork instance, registering it a CurrentUnitOfWork. |
|
| Methods inherited from class org.axonframework.unitofwork.AbstractUnitOfWork |
|---|
commit, commitInnerUnitOfWork, doStart, isStarted, rollback, rollback, start |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultUnitOfWork()
| Method Detail |
|---|
public static UnitOfWork startAndGet()
protected void doRollback(Throwable cause)
AbstractUnitOfWork
doRollback in class AbstractUnitOfWorkcause - the cause of the rollbackprotected void doCommit()
AbstractUnitOfWork
doCommit in class AbstractUnitOfWork
public <T extends AggregateRoot> void registerAggregate(T aggregate,
SaveAggregateCallback<T> callback)
UnitOfWork
T - the type of aggregate to registeraggregate - The aggregate root to register in the UnitOfWorkcallback - The callback that is invoked when the UnitOfWork wants to store the registered
aggregatepublic void registerListener(UnitOfWorkListener listener)
UnitOfWork
listener - The listener to notify when the UnitOfWork's state changes.
public void publishEvent(Event event,
EventBus eventBus)
UnitOfWorkevent on the given eventBus. The UnitOfWork may either
publish immediately, or buffer the events until the UnitOfWork is committed.
event - The event to be published on the event buseventBus - The event bus on which to publish the eventprotected void notifyListenersRollback(Throwable cause)
UnitOfWorkListener.onRollback(Throwable) notification to all registered listeners.
notifyListenersRollback in class AbstractUnitOfWorkcause - The cause of the rollbackprotected void notifyListenersAfterCommit()
UnitOfWorkListener.afterCommit() notification to all registered listeners.
protected void publishEvents()
protected void saveAggregates()
AbstractUnitOfWork
saveAggregates in class AbstractUnitOfWorkprotected void notifyListenersPrepareCommit()
AbstractUnitOfWorkUnitOfWorkListener.onPrepareCommit(java.util.Set, java.util.List)
notification to all registered listeners.
notifyListenersPrepareCommit in class AbstractUnitOfWorkprotected void notifyListenersCleanup()
UnitOfWorkListener.onCleanup() notification to all registered
listeners.
notifyListenersCleanup in class AbstractUnitOfWork
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||