Package io.agroal.api.transaction
Interface TransactionAware
-
public interface TransactionAwareInterface to be implemented by a resource (a connection) that the transaction integration layer will manipulate.- Author:
- Luis Barreiro, Jesper Pedersen
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTransactionAware.SQLCallable<T>A callable that can throwSQLException
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectgetConnection()Gets access to the rawConnectionheld by the resource.voidsetFlushOnly()The resource is no longer valid and should not be returned to the pool.voidtransactionBeforeCompletion(boolean successful)The transaction is about to complete.voidtransactionCheckCallback(TransactionAware.SQLCallable<Boolean> transactionCheck)Set a callback trap to prevent lazy / deferred enlistment.voidtransactionCommit()The resource must commit.voidtransactionEnd()The transaction ended and the resource is no longer enlisted.voidtransactionRollback()The resource must rollback.voidtransactionStart()The resource it's now enlisted with a transaction.
-
-
-
Method Detail
-
transactionStart
void transactionStart() throws SQLExceptionThe resource it's now enlisted with a transaction.- Throws:
SQLException
-
transactionBeforeCompletion
void transactionBeforeCompletion(boolean successful)
The transaction is about to complete.- Parameters:
successful- If the transaction is to complete successfully (commit) or unsuccessfully (rollback)
-
transactionCommit
void transactionCommit() throws SQLExceptionThe resource must commit.- Throws:
SQLException
-
transactionRollback
void transactionRollback() throws SQLExceptionThe resource must rollback.- Throws:
SQLException
-
transactionEnd
void transactionEnd() throws SQLExceptionThe transaction ended and the resource is no longer enlisted.- Throws:
SQLException
-
transactionCheckCallback
void transactionCheckCallback(TransactionAware.SQLCallable<Boolean> transactionCheck)
Set a callback trap to prevent lazy / deferred enlistment. Agroal supports neither of those features. This callback is set when the resource is obtained outside the scope of a running transaction and allows the resource to check if it's used within a transaction later on.
-
getConnection
Object getConnection()
Gets access to the rawConnectionheld by the resource.
-
setFlushOnly
void setFlushOnly()
The resource is no longer valid and should not be returned to the pool.
-
-