Package org.jdbi.v3.core
Class LazyHandleSupplier
- java.lang.Object
-
- org.jdbi.v3.core.AbstractHandleSupplier
-
- org.jdbi.v3.core.LazyHandleSupplier
-
- All Implemented Interfaces:
java.lang.AutoCloseable,HandleSupplier,OnDemandHandleSupplier
final class LazyHandleSupplier extends AbstractHandleSupplier implements OnDemandHandleSupplier
-
-
Field Summary
Fields Modifier and Type Field Description private MemoizingSupplier<Handle>handleHolderprivate Jdbijdbi
-
Constructor Summary
Constructors Constructor Description LazyHandleSupplier(Jdbi jdbi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private HandlecreateHandle()ConfigRegistrygetConfig()Returns the current Jdbi config.HandlegetHandle()Returns a handle, possibly creating it lazily.JdbigetJdbi()Returns the owning Jdbi instance.protected voidwithHandle(java.util.function.Consumer<Handle> handleConsumer)-
Methods inherited from class org.jdbi.v3.core.AbstractHandleSupplier
currentExtensionContext, invokeInContext
-
-
-
-
Field Detail
-
jdbi
private final Jdbi jdbi
-
handleHolder
private final MemoizingSupplier<Handle> handleHolder
-
-
Constructor Detail
-
LazyHandleSupplier
LazyHandleSupplier(Jdbi jdbi)
-
-
Method Detail
-
getConfig
public ConfigRegistry getConfig()
Description copied from interface:HandleSupplierReturns the current Jdbi config.- Specified by:
getConfigin interfaceHandleSupplier- Returns:
- The current Jdbi configuration.
-
getJdbi
public Jdbi getJdbi()
Description copied from interface:HandleSupplierReturns the owning Jdbi instance.- Specified by:
getJdbiin interfaceHandleSupplier- Returns:
- The owning Jdbi instance.
-
getHandle
public Handle getHandle()
Description copied from interface:HandleSupplierReturns a handle, possibly creating it lazily. A Handle holds a database connection, so extensions should only call this method in order to interact with the database.- Specified by:
getHandlein interfaceHandleSupplier- Returns:
- An open Handle.
-
createHandle
private Handle createHandle()
-
withHandle
protected void withHandle(java.util.function.Consumer<Handle> handleConsumer)
- Specified by:
withHandlein classAbstractHandleSupplier
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceHandleSupplier- Overrides:
closein classAbstractHandleSupplier
-
-