Class GenericHandleAwareUnitOfWorkFactory<UOW extends HandleAwareUnitOfWork>
- java.lang.Object
-
- dk.cloudcreate.essentials.components.foundation.transaction.jdbi.GenericHandleAwareUnitOfWorkFactory<UOW>
-
- Type Parameters:
UOW- the concreteHandleAwareUnitOfWork- such as theGenericHandleAwareUnitOfWorkFactory.GenericHandleAwareUnitOfWork
- All Implemented Interfaces:
HandleAwareUnitOfWorkFactory<UOW>,UnitOfWorkFactory<UOW>
- Direct Known Subclasses:
JdbiUnitOfWorkFactory
public abstract class GenericHandleAwareUnitOfWorkFactory<UOW extends HandleAwareUnitOfWork> extends Object implements HandleAwareUnitOfWorkFactory<UOW>
GenericHandleAwareUnitOfWorkFactoryvariant where the implementation manually manages theUnitOfWorkand the underlying database Transaction.
This class is built for inheritance, but can also be used directly - e.g. through theJdbiUnitOfWorkFactory
If you e.g. need to have aUnitOfWorkjoin in with an existing Spring Managed transaction then please use the Spring specificUnitOfWorkFactory,SpringManagedUnitOfWorkFactory, provided with the spring-postgresql-event-store module.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGenericHandleAwareUnitOfWorkFactory.GenericHandleAwareUnitOfWork
-
Field Summary
-
Fields inherited from interface dk.cloudcreate.essentials.components.foundation.transaction.UnitOfWorkFactory
unitOfWorkLog
-
-
Constructor Summary
Constructors Constructor Description GenericHandleAwareUnitOfWorkFactory(org.jdbi.v3.core.Jdbi jdbi)Example of using the GenericHandleAwareUnitOfWorkFactory directly
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract UOWcreateNewUnitOfWorkInstance(GenericHandleAwareUnitOfWorkFactory<UOW> unitOfWorkFactory)Optional<UOW>getCurrentUnitOfWork()Get the currently activeUnitOfWorkUOWgetOrCreateNewUnitOfWork()Get the currently activeUnitOfWorkor create a newUnitOfWorkif one is missingUOWgetRequiredUnitOfWork()Get a required activeUnitOfWork-
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.UnitOfWorkFactory
usingUnitOfWork, usingUnitOfWork, withUnitOfWork, withUnitOfWork
-
-
-
-
Constructor Detail
-
GenericHandleAwareUnitOfWorkFactory
public GenericHandleAwareUnitOfWorkFactory(org.jdbi.v3.core.Jdbi jdbi)
Example of using the GenericHandleAwareUnitOfWorkFactory directly{@code unitOfWorkFactory = new GenericHandleAwareUnitOfWorkFactory<>(jdbi) {- Parameters:
jdbi- the jdbi instance which provides access to the underlying database
-
-
Method Detail
-
getRequiredUnitOfWork
public UOW getRequiredUnitOfWork()
Description copied from interface:UnitOfWorkFactoryGet a required activeUnitOfWork- Specified by:
getRequiredUnitOfWorkin interfaceUnitOfWorkFactory<UOW extends HandleAwareUnitOfWork>- Returns:
- the active
UnitOfWork
-
getOrCreateNewUnitOfWork
public UOW getOrCreateNewUnitOfWork()
Description copied from interface:UnitOfWorkFactoryGet the currently activeUnitOfWorkor create a newUnitOfWorkif one is missing- Specified by:
getOrCreateNewUnitOfWorkin interfaceUnitOfWorkFactory<UOW extends HandleAwareUnitOfWork>- Returns:
- a
UnitOfWork
-
createNewUnitOfWorkInstance
protected abstract UOW createNewUnitOfWorkInstance(GenericHandleAwareUnitOfWorkFactory<UOW> unitOfWorkFactory)
-
getCurrentUnitOfWork
public Optional<UOW> getCurrentUnitOfWork()
Description copied from interface:UnitOfWorkFactoryGet the currently activeUnitOfWork- Specified by:
getCurrentUnitOfWorkin interfaceUnitOfWorkFactory<UOW extends HandleAwareUnitOfWork>- Returns:
- the currently active
UnitOfWorkwrapped in anOptionalorOptional.empty()in case there isn't a currently activeUnitOfWork
-
-