|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.unitofwork.UnitOfWorkListenerCollection
public class UnitOfWorkListenerCollection
This class is responsible for notifying registered listeners in a specific order of precedence.
When onPrepareCommit(UnitOfWork, java.util.Set, java.util.List)
} and
onEventRegistered(UnitOfWork, org.axonframework.domain.EventMessage)
are called the listeners will be
handled in the order they have been registered (order of precedence). When afterCommit(UnitOfWork)
, onRollback(UnitOfWork, Throwable)
, and onCleanup(UnitOfWork)
are called the listeners will be handled in
the reversed order of precedence.
AuditingUnitOfWorkListener
should write an entry before any other listeners are allowed to anything (prepare commit)
and write an entry only after all other listeners have successfully committed (after commit).
Constructor Summary | |
---|---|
UnitOfWorkListenerCollection()
|
Method Summary | ||
---|---|---|
void |
add(UnitOfWorkListener listener)
Adds a listener to the collection. |
|
void |
afterCommit(UnitOfWork unitOfWork)
Invoked when the UnitOfWork is committed. |
|
void |
onCleanup(UnitOfWork unitOfWork)
Notifies listeners that the UnitOfWork is being cleaned up. |
|
|
onEventRegistered(UnitOfWork unitOfWork,
EventMessage<T> event)
Invoked when an Event is registered for publication when the UnitOfWork is committed. |
|
void |
onPrepareCommit(UnitOfWork unitOfWork,
Set<AggregateRoot> aggregateRoots,
List<EventMessage> events)
Invoked before aggregates are committed, and before any events are published. |
|
void |
onPrepareTransactionCommit(UnitOfWork unitOfWork,
Object transaction)
Invoked before the transaction bound to this Unit of Work is committed, but after all other commit activities (publication of events and saving of aggregates) are performed. |
|
void |
onRollback(UnitOfWork unitOfWork,
Throwable failureCause)
Invoked when the UnitOfWork is rolled back. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UnitOfWorkListenerCollection()
Method Detail |
---|
public void afterCommit(UnitOfWork unitOfWork)
UnitOfWorkListener.onRollback(UnitOfWork, Throwable)
consecutively.
Listeners are called in the reversed order of precedence.
afterCommit
in interface UnitOfWorkListener
unitOfWork
- The Unit of Work being committedUnitOfWork.commit()
public void onRollback(UnitOfWork unitOfWork, Throwable failureCause)
onRollback
in interface UnitOfWorkListener
unitOfWork
- The Unit of Work being rolled backfailureCause
- The exception (or error) causing the roll backUnitOfWork.rollback(Throwable)
public <T> EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event)
event
.
Listeners are called in the order of precedence.
onEventRegistered
in interface UnitOfWorkListener
T
- The type of payload of the EventMessageunitOfWork
- The Unit of Work on which an event is registeredevent
- The event about to be registered for publication
public void onPrepareCommit(UnitOfWork unitOfWork, Set<AggregateRoot> aggregateRoots, List<EventMessage> events)
events
may not contain the uncommitted domain events of each of the
aggregateRoots
. To retrieve all events, collect all uncommitted events from the aggregate roots and
combine them with the list of events.
Listeners are called in the order of precedence.
onPrepareCommit
in interface UnitOfWorkListener
unitOfWork
- The Unit of Work being committedaggregateRoots
- the aggregate roots being committedevents
- Events that have been registered for dispatching with the UnitOfWorkpublic void onPrepareTransactionCommit(UnitOfWork unitOfWork, Object transaction)
UnitOfWorkListener
onPrepareTransactionCommit
in interface UnitOfWorkListener
unitOfWork
- The Unit of Work of which the underlying transaction is being committed.transaction
- The object representing the (status of) the transaction, as returned by TransactionManager.startTransaction()
.TransactionManager
public void onCleanup(UnitOfWork unitOfWork)
onCleanup
in interface UnitOfWorkListener
unitOfWork
- The Unit of Work being cleaned uppublic void add(UnitOfWorkListener listener)
listener
- the listener to be added
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |