Package org.jdbi.v3.core
Class AbstractHandleSupplier
- java.lang.Object
-
- org.jdbi.v3.core.AbstractHandleSupplier
-
- All Implemented Interfaces:
java.lang.AutoCloseable,HandleSupplier
- Direct Known Subclasses:
ConstantHandleSupplier,LazyHandleSupplier
abstract class AbstractHandleSupplier extends java.lang.Object implements HandleSupplier
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBooleanclosedprivate java.util.Deque<ExtensionContext>extensionContexts
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHandleSupplier()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()protected ExtensionContextcurrentExtensionContext()Returns the current extension context or null if none exists.<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.private voidpopExtensionContext()private voidpushExtensionContext(ExtensionContext extensionContext)protected abstract voidwithHandle(java.util.function.Consumer<Handle> handleConsumer)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jdbi.v3.core.extension.HandleSupplier
getConfig, getHandle, getJdbi
-
-
-
-
Field Detail
-
closed
private final java.util.concurrent.atomic.AtomicBoolean closed
-
extensionContexts
private final java.util.Deque<ExtensionContext> extensionContexts
-
-
Method Detail
-
invokeInContext
public <V> V invokeInContext(ExtensionContext extensionContext, java.util.concurrent.Callable<V> task) throws java.lang.Exception
Description copied from interface:HandleSupplierBind a newExtensionContextto the Handle, invoke the given task, then restore the Handle's extension state.- Specified by:
invokeInContextin interfaceHandleSupplier- 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
-
currentExtensionContext
protected ExtensionContext currentExtensionContext()
Returns the current extension context or null if none exists.
-
withHandle
protected abstract void withHandle(java.util.function.Consumer<Handle> handleConsumer)
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceHandleSupplier
-
pushExtensionContext
private void pushExtensionContext(ExtensionContext extensionContext)
-
popExtensionContext
private void popExtensionContext()
-
-