Class SpringTransactionAwareUnitOfWorkFactory<TRX_MGR extends org.springframework.transaction.PlatformTransactionManager,UOW extends SpringTransactionAwareUnitOfWork<TRX_MGR,UOW>>
java.lang.Object
dk.cloudcreate.essentials.components.foundation.transaction.spring.SpringTransactionAwareUnitOfWorkFactory<TRX_MGR,UOW>
- Type Parameters:
TRX_MGR- the platform transaction manager that thisUnitOfWorkFactoryis compatible withUOW- the Unit of work implementation that thisSpringTransactionAwareUnitOfWorkFactoryspecialization is compatible with
- All Implemented Interfaces:
UnitOfWorkFactory<UOW>
- Direct Known Subclasses:
SpringMongoTransactionAwareUnitOfWorkFactory,SpringTransactionAwareJdbiUnitOfWorkFactory
public abstract class SpringTransactionAwareUnitOfWorkFactory<TRX_MGR extends org.springframework.transaction.PlatformTransactionManager,UOW extends SpringTransactionAwareUnitOfWork<TRX_MGR,UOW>>
extends Object
implements UnitOfWorkFactory<UOW>
Variant of the
The
UnitOfWorkFactory which can delegate the creation of the underlying transaction to the provided PlatformTransactionManager instance.The
UnitOfWork type specialization needs to extend SpringTransactionAwareUnitOfWork-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.springframework.transaction.support.DefaultTransactionDefinitionprotected static final org.slf4j.Loggerprotected final TRX_MGRprotected final Class<?>The class representation of theUOWgeneric type parameter.
TheUnitOfWorkis bound a resource with theTransactionSynchronizationManagerusing theunitOfWorkTypeclass as key.Fields inherited from interface dk.cloudcreate.essentials.components.foundation.transaction.UnitOfWorkFactory
unitOfWorkLog -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterCommitAfterCallingLifecycleCallbackResources(UOW unitOfWork) Called duringTransactionSynchronization.afterCommit()AFTER all registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterCommit(UnitOfWork, List)method calledprotected voidCalled duringTransactionSynchronization.afterCommit()BEFORE any registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterCommit(UnitOfWork, List)method calledprotected voidCalled duringTransactionSynchronization.afterCompletion(int)AFTER all registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterRollback(UnitOfWork, List, Exception)method calledprotected voidCalled duringTransactionSynchronization.afterCompletion(int)BEFORE any registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterRollback(UnitOfWork, List, Exception)method calledprotected voidCalled duringTransactionSynchronization.beforeCommit(boolean)AFTER all registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.beforeCommit(UnitOfWork, List)method calledprotected voidCalled duringTransactionSynchronization.beforeCommit(boolean)BEFORE any registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.beforeCommit(UnitOfWork, List)method calledprotected org.springframework.transaction.support.DefaultTransactionDefinitionOverride to create a customDefaultTransactionDefinition.protected abstract UOWcreateUnitOfWorkForFactoryManagedTransaction(org.springframework.transaction.TransactionStatus transaction) Create aUnitOfWorkwrapping a Spring Transaction managed by thisUnitOfWorkFactoryprotected abstract UOWCreate aUnitOfWorkparticipating in an existing Spring Managed Transaction that isn't managed by thisUnitOfWorkFactoryGet the currently activeUnitOfWorkGet the currently activeUnitOfWorkor create a newUnitOfWorkif one is missingGet a required activeUnitOfWorkprotected Class<?>Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dk.cloudcreate.essentials.components.foundation.transaction.UnitOfWorkFactory
usingUnitOfWork, usingUnitOfWork, withUnitOfWork, withUnitOfWork
-
Field Details
-
log
protected static final org.slf4j.Logger log -
transactionManager
protected final TRX_MGR extends org.springframework.transaction.PlatformTransactionManager transactionManager -
defaultTransactionDefinition
protected final org.springframework.transaction.support.DefaultTransactionDefinition defaultTransactionDefinition -
unitOfWorkType
The class representation of theUOWgeneric type parameter.
TheUnitOfWorkis bound a resource with theTransactionSynchronizationManagerusing theunitOfWorkTypeclass as key.
-
-
Constructor Details
-
SpringTransactionAwareUnitOfWorkFactory
-
-
Method Details
-
resolveUnitOfWorkType
-
createDefaultTransactionDefinition
protected org.springframework.transaction.support.DefaultTransactionDefinition createDefaultTransactionDefinition()Override to create a customDefaultTransactionDefinition.- Returns:
- per default, it generates a
DefaultTransactionDefinitionwith propagationTransactionDefinition.PROPAGATION_REQUIREDand Isolation-levelTransactionDefinition.ISOLATION_READ_COMMITTED
-
getTransactionManager
-
getRequiredUnitOfWork
Description copied from interface:UnitOfWorkFactoryGet a required activeUnitOfWork- Specified by:
getRequiredUnitOfWorkin interfaceUnitOfWorkFactory<TRX_MGR extends org.springframework.transaction.PlatformTransactionManager>- Returns:
- the active
UnitOfWork
-
getCurrentUnitOfWork
Description copied from interface:UnitOfWorkFactoryGet the currently activeUnitOfWork- Specified by:
getCurrentUnitOfWorkin interfaceUnitOfWorkFactory<TRX_MGR extends org.springframework.transaction.PlatformTransactionManager>- Returns:
- the currently active
UnitOfWorkwrapped in anOptionalorOptional.empty()in case there isn't a currently activeUnitOfWork
-
getOrCreateNewUnitOfWork
Description copied from interface:UnitOfWorkFactoryGet the currently activeUnitOfWorkor create a newUnitOfWorkif one is missing- Specified by:
getOrCreateNewUnitOfWorkin interfaceUnitOfWorkFactory<TRX_MGR extends org.springframework.transaction.PlatformTransactionManager>- Returns:
- a
UnitOfWork
-
createUnitOfWorkForFactoryManagedTransaction
protected abstract UOW createUnitOfWorkForFactoryManagedTransaction(org.springframework.transaction.TransactionStatus transaction) Create aUnitOfWorkwrapping a Spring Transaction managed by thisUnitOfWorkFactory- Parameters:
transaction- the Spring Transaction managed by thisUnitOfWorkFactory- Returns:
- a
UnitOfWorkwrapping the existing active Spring managed transaction
-
createUnitOfWorkForSpringManagedTransaction
Create aUnitOfWorkparticipating in an existing Spring Managed Transaction that isn't managed by thisUnitOfWorkFactory- Returns:
- a
UnitOfWorkthat is participating in an existing Spring Managed Transaction that isn't managed by thisUnitOfWorkFactory
-
afterCommitAfterCallingLifecycleCallbackResources
Called duringTransactionSynchronization.afterCommit()AFTER all registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterCommit(UnitOfWork, List)method called- Parameters:
unitOfWork- the unit of work
-
afterCommitBeforeCallingLifecycleCallbackResources
Called duringTransactionSynchronization.afterCommit()BEFORE any registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterCommit(UnitOfWork, List)method called- Parameters:
unitOfWork- the unit of work
-
beforeCommitAfterCallingLifecycleCallbackResources
Called duringTransactionSynchronization.beforeCommit(boolean)AFTER all registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.beforeCommit(UnitOfWork, List)method called- Parameters:
unitOfWork- the unit of work
-
beforeCommitBeforeCallingLifecycleCallbackResources
Called duringTransactionSynchronization.beforeCommit(boolean)BEFORE any registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.beforeCommit(UnitOfWork, List)method called- Parameters:
unitOfWork- the unit of work
-
afterRollbackBeforeCallingLifecycleCallbackResources
Called duringTransactionSynchronization.afterCompletion(int)BEFORE any registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterRollback(UnitOfWork, List, Exception)method called- Parameters:
unitOfWork- the unit of work
-
afterRollbackAfterCallingLifecycleCallbackResources
Called duringTransactionSynchronization.afterCompletion(int)AFTER all registeredSpringTransactionAwareUnitOfWork.unitOfWorkLifecycleCallbackResourceshave had theirUnitOfWorkLifecycleCallback.afterRollback(UnitOfWork, List, Exception)method called- Parameters:
unitOfWork- the unit of work
-