Class GenericHandleAwareUnitOfWorkFactory.GenericHandleAwareUnitOfWork
- java.lang.Object
-
- dk.cloudcreate.essentials.components.foundation.transaction.jdbi.GenericHandleAwareUnitOfWorkFactory.GenericHandleAwareUnitOfWork
-
- All Implemented Interfaces:
HandleAwareUnitOfWork,UnitOfWork
- Enclosing class:
- GenericHandleAwareUnitOfWorkFactory<UOW extends HandleAwareUnitOfWork>
public static class GenericHandleAwareUnitOfWorkFactory.GenericHandleAwareUnitOfWork extends Object implements HandleAwareUnitOfWork
-
-
Constructor Summary
Constructors Constructor Description GenericHandleAwareUnitOfWork(GenericHandleAwareUnitOfWorkFactory<?> unitOfWorkFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterClosingHandle()Called right after theHandleis closed.protected voidafterCommitting()Called right afterHandle.commit()has been called.protected voidafterRollback(Exception cause)Called right afterHandle.rollback()has been called.protected voidbeforeCommitting()Called right beforeHandle.commit()is called.protected voidbeforeRollback(Exception cause)Called right beforeHandle.rollback()is called.voidcommit()Commit theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.CommittedExceptiongetCauseOfRollback()The cause of a Rollback or aUnitOfWork.markAsRollbackOnly(Exception)org.jdbi.v3.core.Handlehandle()voidmarkAsRollbackOnly(Exception cause)<T> TregisterLifecycleCallbackForResource(T resource, UnitOfWorkLifecycleCallback<T> associatedUnitOfWorkCallback)TODO: Adjust example to the new API Register a resource (e.g.voidrollback(Exception cause)Roll back theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.RolledBackvoidstart()Start theUnitOfWorkand any underlying transactionUnitOfWorkStatusstatus()Get the status of theUnitOfWork-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface dk.cloudcreate.essentials.components.foundation.transaction.UnitOfWork
markAsRollbackOnly, rollback
-
-
-
-
Constructor Detail
-
GenericHandleAwareUnitOfWork
public GenericHandleAwareUnitOfWork(GenericHandleAwareUnitOfWorkFactory<?> unitOfWorkFactory)
-
-
Method Detail
-
start
public void start()
Description copied from interface:UnitOfWorkStart theUnitOfWorkand any underlying transaction- Specified by:
startin interfaceUnitOfWork
-
commit
public void commit()
Description copied from interface:UnitOfWorkCommit theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.Committed- Specified by:
commitin interfaceUnitOfWork
-
rollback
public void rollback(Exception cause)
Description copied from interface:UnitOfWorkRoll back theUnitOfWorkand any underlying transaction - seeUnitOfWorkStatus.RolledBack- Specified by:
rollbackin interfaceUnitOfWork- Parameters:
cause- the cause of the rollback
-
registerLifecycleCallbackForResource
public <T> T registerLifecycleCallbackForResource(T resource, UnitOfWorkLifecycleCallback<T> associatedUnitOfWorkCallback)Description copied from interface:UnitOfWorkTODO: Adjust example to the new API Register a resource (e.g. an Aggregate) that should have itsUnitOfWorkLifecycleCallbackcalled duringUnitOfWorkoperation.
Example:
Where the AggregAggregate aggregate = unitOfWork.registerLifecycleCallbackForResource(aggregate.loadFromEvents(event), new AggregateRootRepositoryUnitOfWorkLifecycleCallback()));{@code class AggregateRootRepositoryUnitOfWorkLifecycleCallback implements UnitOfWorkLifecycleCallback{ - Specified by:
registerLifecycleCallbackForResourcein interfaceUnitOfWork- Type Parameters:
T- the type of resource- Parameters:
resource- the resource that should be trackedassociatedUnitOfWorkCallback- the callback instance for the given resource- Returns:
- the
resourceor a proxy to it
-
status
public UnitOfWorkStatus status()
Description copied from interface:UnitOfWorkGet the status of theUnitOfWork- Specified by:
statusin interfaceUnitOfWork
-
getCauseOfRollback
public Exception getCauseOfRollback()
Description copied from interface:UnitOfWorkThe cause of a Rollback or aUnitOfWork.markAsRollbackOnly(Exception)- Specified by:
getCauseOfRollbackin interfaceUnitOfWork
-
markAsRollbackOnly
public void markAsRollbackOnly(Exception cause)
- Specified by:
markAsRollbackOnlyin interfaceUnitOfWork
-
handle
public org.jdbi.v3.core.Handle handle()
Description copied from interface:HandleAwareUnitOfWork- Specified by:
handlein interfaceHandleAwareUnitOfWork- Returns:
- the
Jdbihandle associated with the currentUnitOfWork
-
afterClosingHandle
protected void afterClosingHandle()
Called right after theHandleis closed. Perform any additional clean-ups by overriding this method
-
afterCommitting
protected void afterCommitting()
Called right afterHandle.commit()has been called.
-
beforeCommitting
protected void beforeCommitting()
Called right beforeHandle.commit()is called.
-
afterRollback
protected void afterRollback(Exception cause)
Called right afterHandle.rollback()has been called.- Parameters:
cause- the cause of the rollback
-
beforeRollback
protected void beforeRollback(Exception cause)
Called right beforeHandle.rollback()is called.- Parameters:
cause- the cause of the rollback
-
-