Top Description Methods
org.jooq

public Interface ResourceManagingScope

extends Scope
Known Direct Subinterfaces
org.jooq.impl.ResourceManagingScopeTrait, org.jooq.BindingSetSQLOutputContext, org.jooq.BindingSetStatementContext
Imports
java.io.Closeable, .InputStream, java.sql.Array, .Blob, .Clob, .SQLXML

A scope that can manage resources.

This is a type of Scope that can manage resources on behalf of the call site, and free / close those resources once the scope ends.

For example, Binding implementations may wish to create Clob or InputStream or 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 of ThreadLocal, 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())));
    }
}

This type is a Scope with whose lifecycle is typically tied to an ExecuteContext, sharing the latter's data() map.

Author
Lukas Eder

Method Summary

Modifier and TypeMethod and Description
public <R extends Closeable> R

Returns:

The argument closeable, for convenience.
autoClose
(R closeable)

Register a Closeable for auto closing after this scope ends.

public <R extends AutoCloseable> R

Returns:

The argument closeable, for convenience.
autoClose
(R closeable)

Register an AutoCloseable for auto closing after this scope ends.

public Array

Returns:

The argument array, for convenience.
autoFree
(Array array)

Register a Array for auto freeing after this scope ends.

public Blob

Returns:

The argument blob, for convenience.
autoFree
(Blob blob)

Register a Blob for auto freeing after this scope ends.

public Clob

Returns:

The argument clob, for convenience.
autoFree
(Clob clob)

Register a Clob for auto freeing after this scope ends.

public SQLXML

Returns:

The argument xml, for convenience.
autoFree
(SQLXML xml)

Register a SQLXML for auto freeing after this scope ends.

Inherited from org.jooq.Scope:
configurationcreationTimedatadatadatadialectdslfamilysettings

Method Detail

autoCloseback to summary
public <R extends Closeable> R autoClose(R closeable)

Register a Closeable for auto closing after this scope ends.

Returns:R

The argument closeable, for convenience.

autoCloseback to summary
public <R extends AutoCloseable> R autoClose(R closeable)

Register an AutoCloseable for auto closing after this scope ends.

Returns:R

The argument closeable, for convenience.

autoFreeback to summary
public Array autoFree(Array array)

Register a Array for auto freeing after this scope ends.

Returns:Array

The argument array, for convenience.

autoFreeback to summary
public Blob autoFree(Blob blob)

Register a Blob for auto freeing after this scope ends.

Returns:Blob

The argument blob, for convenience.

autoFreeback to summary
public Clob autoFree(Clob clob)

Register a Clob for auto freeing after this scope ends.

Returns:Clob

The argument clob, for convenience.

autoFreeback to summary
public SQLXML autoFree(SQLXML xml)

Register a SQLXML for auto freeing after this scope ends.

Returns:SQLXML

The argument xml, for convenience.