public class AuditingUnitOfWorkListener extends UnitOfWorkListenerAdapter
Constructor and Description |
---|
AuditingUnitOfWorkListener(CommandMessage<?> command,
AuditDataProvider auditDataProvider,
AuditLogger auditLogger)
Initialize a listener for the given
command . |
Modifier and Type | Method and Description |
---|---|
void |
afterCommit(UnitOfWork unitOfWork)
Invoked when the UnitOfWork is committed.
|
<T> EventMessage<T> |
onEventRegistered(UnitOfWork unitOfWork,
EventMessage<T> event)
Invoked when an Event is registered for publication when the UnitOfWork is committed.
|
void |
onRollback(UnitOfWork unitOfWork,
Throwable failureCause)
Invoked when the UnitOfWork is rolled back.
|
onCleanup, onPrepareCommit, onPrepareTransactionCommit
public AuditingUnitOfWorkListener(CommandMessage<?> command, AuditDataProvider auditDataProvider, AuditLogger auditLogger)
command
. The auditDataProvider
is called before
the Unit Of Work is committed to provide the auditing information. The auditLogger
is invoked after
the Unit Of Work is successfully committed.command
- The command being auditedauditDataProvider
- The instance providing the information to attach to the eventsauditLogger
- The logger writing the auditpublic void afterCommit(UnitOfWork unitOfWork)
UnitOfWorkListenerAdapter
UnitOfWorkListener.onRollback(UnitOfWork, Throwable)
consecutively.afterCommit
in interface UnitOfWorkListener
afterCommit
in class UnitOfWorkListenerAdapter
unitOfWork
- The Unit of Work being committedUnitOfWork.commit()
public void onRollback(UnitOfWork unitOfWork, Throwable failureCause)
UnitOfWorkListenerAdapter
onRollback
in interface UnitOfWorkListener
onRollback
in class UnitOfWorkListenerAdapter
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)
UnitOfWorkListenerAdapter
event
.onEventRegistered
in interface UnitOfWorkListener
onEventRegistered
in class UnitOfWorkListenerAdapter
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 publicationCopyright © 2010-2014. All Rights Reserved.