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>
Generic
This class is built for inheritance, but can also be used directly - e.g. through the
If you e.g. need to have a
HandleAwareUnitOfWorkFactory variant where the implementation manually
manages the UnitOfWork and the underlying database Transaction.This class is built for inheritance, but can also be used directly - e.g. through the
JdbiUnitOfWorkFactoryIf you e.g. need to have a
UnitOfWork join in with an
existing Spring Managed transaction then please use the Spring specific UnitOfWorkFactory,
SpringManagedUnitOfWorkFactory, provided with the spring-postgresql-event-store module.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
Fields inherited from interface dk.cloudcreate.essentials.components.foundation.transaction.UnitOfWorkFactory
unitOfWorkLog -
Constructor Summary
ConstructorsConstructorDescriptionGenericHandleAwareUnitOfWorkFactory(org.jdbi.v3.core.Jdbi jdbi) Example of using the GenericHandleAwareUnitOfWorkFactory directly -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract UOWcreateNewUnitOfWorkInstance(GenericHandleAwareUnitOfWorkFactory<UOW> unitOfWorkFactory) Get the currently activeUnitOfWorkGet the currently activeUnitOfWorkor create a newUnitOfWorkif one is missingGet a required activeUnitOfWorkMethods 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
-
Constructor Details
-
GenericHandleAwareUnitOfWorkFactory
public GenericHandleAwareUnitOfWorkFactory(org.jdbi.v3.core.Jdbi jdbi) Example of using the GenericHandleAwareUnitOfWorkFactory directlyunitOfWorkFactory = new GenericHandleAwareUnitOfWorkFactory<>(jdbi) { @Override protected GenericHandleAwareUnitOfWork createNewUnitOfWorkInstance(GenericHandleAwareUnitOfWorkFactory<GenericHandleAwareUnitOfWork> unitOfWorkFactory) { return new GenericHandleAwareUnitOfWork(unitOfWorkFactory); } };- Parameters:
jdbi- the jdbi instance which provides access to the underlying database
-
-
Method Details
-
getRequiredUnitOfWork
Description copied from interface:UnitOfWorkFactoryGet a required activeUnitOfWork- Specified by:
getRequiredUnitOfWorkin interfaceUnitOfWorkFactory<UOW extends HandleAwareUnitOfWork>- Returns:
- the active
UnitOfWork
-
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
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
-