Package org.jdbi.v3.core.extension
Interface HandleSupplier
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
AbstractHandleSupplier,ConstantHandleSupplier,LazyHandleSupplier
public interface HandleSupplier extends java.lang.AutoCloseableA handle supplier for extension implementors.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()ConfigRegistrygetConfig()Returns the current Jdbi config.HandlegetHandle()Returns a handle, possibly creating it lazily.JdbigetJdbi()Returns the owning Jdbi instance.<V> VinvokeInContext(ExtensionContext extensionContext, java.util.concurrent.Callable<V> task)Bind a newExtensionContextto the Handle, invoke the given task, then restore the Handle's extension state.
-
-
-
Method Detail
-
getHandle
Handle getHandle()
Returns 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.- Returns:
- An open Handle.
-
getJdbi
Jdbi getJdbi()
Returns the owning Jdbi instance.- Returns:
- The owning Jdbi instance.
-
getConfig
ConfigRegistry getConfig()
Returns the current Jdbi config.- Returns:
- The current Jdbi configuration.
-
invokeInContext
<V> V invokeInContext(ExtensionContext extensionContext, java.util.concurrent.Callable<V> task) throws java.lang.Exception
Bind a newExtensionContextto the Handle, invoke the given task, then restore the Handle's extension state.- Type Parameters:
V- the result type of the task- Parameters:
extensionContext- AnExtensionContextobject that manages the extension state.task- the code to execute in an extension context- Returns:
- the callable's result
- Throws:
java.lang.Exception- if any exception is thrown
-
close
default void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-