Package com.atlassian.sal.spi
Interface HostConnectionAccessor
public interface HostConnectionAccessor
Interface allowing SAL to execute a callback with a
Connection, in the context of a transaction.
Host must export this.
Host must implement this; may use com.atlassian.sal.spring.connection.SpringHostConnectionAccessor- Since:
- 3.0
-
Method Summary
Modifier and TypeMethodDescription<A> Aexecute(boolean readOnly, boolean newTransaction, com.atlassian.sal.api.rdbms.ConnectionCallback<A> callback) Execute a callback which is supplied aConnection, within a transaction.io.atlassian.fugue.Option<String>Returns the configured schema name (if any), for connections provided duringexecute(boolean, boolean, ConnectionCallback)
-
Method Details
-
execute
<A> A execute(boolean readOnly, boolean newTransaction, @Nonnull com.atlassian.sal.api.rdbms.ConnectionCallback<A> callback) Execute a callback which is supplied aConnection, within a transaction. It is up to the caller as to whether it attempts to participate in an existing transaction. This is explicitly explained inTransactionalExecutor. In the case of the callback returning normally:- If it is a new connection/transaction that the implementation started then the transaction must be committed, or
- In the case of an existing transaction, the implementation will do nothing and wait for the larger transaction to be committed
- The implementation will mark the transaction as "rollback only" and rethrow the error
autoCommit=false. The following methods are guaranteed not to be called onconnection:Connection.setAutoCommit(boolean)Connection.commit()Connection.close()Connection.rollback()Connection.setReadOnly(boolean)Connection.abort(java.util.concurrent.Executor)Connection.setCatalog(String)Connection.setSchema(String)Connection.setTransactionIsolation(int)Connection.setNetworkTimeout(java.util.concurrent.Executor, int)- Parameters:
readOnly-connectionshould be read onlynewTransaction- attempt to create a new transaction even if there is already a "current" transactioncallback- mandatory- Returns:
- return value of
callback
-
getSchemaName
Returns the configured schema name (if any), for connections provided duringexecute(boolean, boolean, ConnectionCallback)- Returns:
- schema name, if there is one
-