Package org.jdbi.v3.core.extension
Interface HandleSupplier
- All Superinterfaces:
Configurable<HandleSupplier>
A handle supplier for extension implementors.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a handle, possibly creating it lazily.getJdbi()
Returns the owning Jdbi instance.default <V> V
invokeInContext
(ExtensionContext extensionContext, Callable<V> task) Bind a newExtensionContext
to the Handle, invoke the given task, then restore the Handle's extension state.<V> V
invokeInContext
(ExtensionMethod extensionMethod, ConfigRegistry config, Callable<V> task) Deprecated.Methods inherited from interface org.jdbi.v3.core.config.Configurable
addCustomizer, configure, define, getConfig, getConfig, registerArgument, registerArgument, registerArrayType, registerArrayType, registerArrayType, registerArrayType, registerCodecFactory, registerCollector, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerExtension, registerRowMapper, registerRowMapper, registerRowMapper, registerRowMapper, setMapKeyColumn, setMapValueColumn, setSqlArrayArgumentStrategy, setSqlLogger, setSqlParser, setTemplateEngine, setTimingCollector
-
Method Details
-
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.
-
invokeInContext
@Deprecated <V> V invokeInContext(ExtensionMethod extensionMethod, ConfigRegistry config, Callable<V> task) throws Exception Deprecated.New code should implement theinvokeInContext(ExtensionContext, Callable)
method and use this as a retrofit.Bind an extension method and configuration registry to the Handle, invoke the given task, then reset the Handle's extension state. Note that the binding is done by a thread local, so the binding will not propagate to other threads you may call out to.- Type Parameters:
V
- the result type of the task- Parameters:
extensionMethod
- the method invokedconfig
- the configuration registrytask
- the code to execute in an extension context- Returns:
- the callable's result
- Throws:
Exception
- if any exception is thrown- See Also:
-
invokeInContext
Bind a newExtensionContext
to the Handle, invoke the given task, then restore the Handle's extension state.- Type Parameters:
V
- the result type of the task- Parameters:
extensionContext
- AnExtensionContext
object that manages the extension state.task
- the code to execute in an extension context- Returns:
- the callable's result
- Throws:
Exception
- if any exception is thrown
-
invokeInContext(ExtensionContext, Callable)
method and use this as a retrofit.