org.axonframework.unitofwork
Interface UnitOfWorkListener

All Known Implementing Classes:
AuditingUnitOfWorkListener, UnitOfWorkListenerAdapter

public interface UnitOfWorkListener

Interface describing a listener that is notified of state changes in the UnitOfWork it has been registered with.

Since:
0.6
Author:
Allard Buijze

Method Summary
 void afterCommit()
          Invoked when the UnitOfWork is committed.
 void onCleanup()
          Notifies listeners that the UnitOfWork is being cleaned up.
 void onPrepareCommit(Set<AggregateRoot> aggregateRoots, List<Event> events)
          Invoked before aggregates are committed, and before any events are published.
 void onRollback(Throwable failureCause)
          Invoked when the UnitOfWork is rolled back.
 

Method Detail

afterCommit

void afterCommit()
Invoked when the UnitOfWork is committed. The aggregate has been saved and the events have been scheduled for dispatching. In some cases, the events could already have been dispatched. When processing of this method causes an exception, a UnitOfWork may choose to call onRollback(Throwable) consecutively.

See Also:
UnitOfWork.commit()

onRollback

void onRollback(Throwable failureCause)
Invoked when the UnitOfWork is rolled back. The UnitOfWork may choose to invoke this method when committing the UnitOfWork failed, too.

Parameters:
failureCause - The exception (or error) causing the roll back
See Also:
UnitOfWork.rollback(Throwable)

onPrepareCommit

void onPrepareCommit(Set<AggregateRoot> aggregateRoots,
                     List<Event> events)
Invoked before aggregates are committed, and before any events are published. This phase can be used to do validation or other activity that should be able to prevent event dispatching in certain circumstances.

Note that the given 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.

Parameters:
aggregateRoots - the aggregate roots being committed
events - Events that have been registered for dispatching with the UnitOfWork

onCleanup

void onCleanup()
Notifies listeners that the UnitOfWork is being cleaned up. This gives listeners the opportunity to clean up resources that might have been used during commit or rollback, such as remaining locks, open files, etc.

This method is always called after all listeners have been notified of a commit or rollback.



Copyright © 2011. All Rights Reserved.