org.axonframework.unitofwork
Class UnitOfWorkListenerAdapter

java.lang.Object
  extended by org.axonframework.unitofwork.UnitOfWorkListenerAdapter
All Implemented Interfaces:
UnitOfWorkListener

public abstract class UnitOfWorkListenerAdapter
extends Object
implements UnitOfWorkListener

Abstract implementation of the UnitOfWorkListener that provides empty implementation of all methods declared in UnitOfWorkListener. This implementation does nothing.

Since:
0.6
Author:
Allard Buijze

Constructor Summary
UnitOfWorkListenerAdapter()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitOfWorkListenerAdapter

public UnitOfWorkListenerAdapter()
Method Detail

onPrepareCommit

public 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.

Specified by:
onPrepareCommit in interface UnitOfWorkListener
Parameters:
aggregateRoots - the aggregate roots being committed
events - Events that have been registered for dispatching with the UnitOfWork

afterCommit

public 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 UnitOfWorkListener.onRollback(Throwable) consecutively.

Specified by:
afterCommit in interface UnitOfWorkListener
See Also:
UnitOfWork.commit()

onRollback

public 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.

Specified by:
onRollback in interface UnitOfWorkListener
Parameters:
failureCause -
See Also:
UnitOfWork.rollback(Throwable)

onCleanup

public 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.

Specified by:
onCleanup in interface UnitOfWorkListener


Copyright © 2011. All Rights Reserved.