[#2351] Relax ConnectionProvider contract, allowing acquire() to return
new Connections even before release() is called - Updated contract
This commit is contained in:
parent
b4c10646a2
commit
38864c2b16
@ -44,9 +44,9 @@ import org.jooq.exception.DataAccessException;
|
||||
* <p>
|
||||
* The <code>ConnectionProvider</code> allows for abstracting the handling of
|
||||
* custom <code>Connection</code> lifecycles outside of jOOQ, injecting
|
||||
* behaviour into jOOQ's internals. jOOQ will try to get a new JDBC
|
||||
* behaviour into jOOQ's internals. jOOQ will try to acquire a new JDBC
|
||||
* {@link Connection} from the connection provider as early as needed, and will
|
||||
* return it as early as possible.
|
||||
* release it as early as possible.
|
||||
*
|
||||
* @author Aaron Digulla
|
||||
* @author Lukas Eder
|
||||
@ -54,24 +54,35 @@ import org.jooq.exception.DataAccessException;
|
||||
public interface ConnectionProvider {
|
||||
|
||||
/**
|
||||
* Acquire a connection from the connection lifecycle handler
|
||||
* Acquire a connection from the connection lifecycle handler.
|
||||
* <p>
|
||||
* The general contract is that a <code>ConnectionProvider</code> is
|
||||
* expected to always return the same connection, until this connection is
|
||||
* returned by jOOQ through {@link #release(Connection)}.
|
||||
* This method is called by jOOQ exactly once per execution lifecycle, i.e.
|
||||
* per {@link ExecuteContext}. Implementations may freely chose, whether
|
||||
* subsequent calls to this method:
|
||||
* <ul>
|
||||
* <li>return the same connection instance</li>
|
||||
* <li>return the same connection instance for the same thread</li>
|
||||
* <li>return the same connection instance for the same transaction (e.g. a
|
||||
* <code>javax.transaction.UserTransaction</code>)</li>
|
||||
* <li>return a fresh connection instance every time</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* jOOQ will guarantee that every acquired connection is released through
|
||||
* {@link #release(Connection)} exactly once.
|
||||
*
|
||||
* @return A connection for the current <code>ExecuteContext</code>.
|
||||
* @throws DataAccessException If anything went wrong while acquiring a
|
||||
* connection
|
||||
*/
|
||||
Connection acquire() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Release a connection to the connection lifecycle handler
|
||||
* Release a connection to the connection lifecycle handler.
|
||||
* <p>
|
||||
* The general contract is that a <code>ConnectionProvider</code> must not
|
||||
* generate a new connection in {@link #acquire()}, before a previous
|
||||
* connection is returned.
|
||||
* jOOQ will guarantee that every acquired connection is released exactly
|
||||
* once.
|
||||
*
|
||||
* @param A connection that was previously obtained from {@link #acquire()}
|
||||
* @throws DataAccessException If anything went wrong while releasing a
|
||||
* connection
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user