EntityLifecycleMonitor

public final class EntityLifecycleMonitor<I> implements TransactionListener<I>

An implementation of TransactionListener which monitors the transaction flow and triggers the EntityLifecycle.

On a successful Phase, memoizes the ID of the applied message. After a successful transaction commit, passes the memoized IDs to the EntityLifecycle of the entity under transaction, along with the information about the mutations performed under the transaction - an EntityRecordChange.

An instance of this TransactionListener is meant to serve for a single Transaction. When trying to reuse a listener for multiple transactions, an IllegalStateException is thrown.

Parameters

<I>

ID type of the entity under transaction

Functions

Link copied to clipboard
public static EntityLifecycleMonitor<I> newInstance<I>(Repository<I, ? extends Object> repository, I id)
Creates a new instance of EntityLifecycleMonitor.
Link copied to clipboard
public void onAfterCommit(EntityRecordChange change)
A callback invoked after a successful commit.
Link copied to clipboard
public void onAfterPhase(Phase<I> phase)
A callback invoked after applying a transaction phase.
Link copied to clipboard
public void onBeforeCommit(EntityRecord entityRecord)
A callback invoked before committing the transaction.
Link copied to clipboard
public void onBeforePhase(Phase<I> phase)
A callback invoked before applying a transaction phase.
Link copied to clipboard
public void onTransactionFailed(Event cause, EntityRecord entityRecord)
A callback invoked if the commit has failed due to a Rejection.
public void onTransactionFailed(Error cause, EntityRecord entityRecord)
A callback invoked if the commit has failed.