-
- All Superinterfaces:
Scope
- All Known Subinterfaces:
BindingSetSQLOutputContext<U>,BindingSetStatementContext<U>
public interface ResourceManagingScope extends Scope
A scope that can manage resources.This is a type of
Scopethat can manage resources on behalf of the call site, and free / close those resources once the scope ends.For example,
Bindingimplementations may wish to createCloborInputStreamor other kinds of resources in order to bind them to JDBC. Instead of remembering to close them manually through some delicate logic involving e.g. clever usage ofThreadLocal, implementations can register their resources with the methods exposed here, and jOOQ will take care of freeing / closing them at the right moment.Example:
class StreamingLobBinding implements Binding<String, File> { ... public void set(BindingSetStatementContext<File> ctx) { ctx.statement() .setBinaryStream(ctx.index(), ctx.closeAfterExecution(new FileInputStream(ctx.value()))); } }- Author:
- Lukas Eder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <R extends Closeable>
RautoClose(R closeable)Register aCloseablefor auto closing after this scope ends.ArrayautoFree(Array array)Register aArrayfor auto freeing after this scope ends.BlobautoFree(Blob blob)Register aBlobfor auto freeing after this scope ends.ClobautoFree(Clob clob)Register aClobfor auto freeing after this scope ends.SQLXMLautoFree(SQLXML xml)Register aSQLXMLfor auto freeing after this scope ends.
-
-
-
Method Detail
-
autoFree
Array autoFree(Array array)
Register aArrayfor auto freeing after this scope ends.- Returns:
- The argument array, for convenience.
-
autoFree
Blob autoFree(Blob blob)
Register aBlobfor auto freeing after this scope ends.- Returns:
- The argument blob, for convenience.
-
autoFree
Clob autoFree(Clob clob)
Register aClobfor auto freeing after this scope ends.- Returns:
- The argument clob, for convenience.
-
autoFree
SQLXML autoFree(SQLXML xml)
Register aSQLXMLfor auto freeing after this scope ends.- Returns:
- The argument xml, for convenience.
-
autoClose
<R extends Closeable> R autoClose(R closeable)
Register aCloseablefor auto closing after this scope ends.- Returns:
- The argument closeable, for convenience.
-
autoClose
<R extends AutoCloseable> R autoClose(R closeable)
Register anAutoCloseablefor auto closing after this scope ends.- Returns:
- The argument closeable, for convenience.
-
-