Class CopperTransactionController
- java.lang.Object
-
- org.copperengine.core.persistent.txn.CopperTransactionController
-
- All Implemented Interfaces:
TransactionController
public class CopperTransactionController extends java.lang.Object implements TransactionController
Implementation of theTransactionController
interface that internally uses COPPERsRetryingTransaction
for transaction management
-
-
Constructor Summary
Constructors Constructor Description CopperTransactionController()
CopperTransactionController(javax.sql.DataSource dataSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
run(DatabaseTransaction<T> txn)
Runs a database transaction, i.e.<T> T
run(Transaction<T> txn)
Runs a transaction, the provided DatabaseTransaction object is executed in the scope of a transaction.void
setDataSource(javax.sql.DataSource dataSource)
void
setMaxConnectRetries(int maxConnectRetries)
-
-
-
Method Detail
-
setDataSource
public void setDataSource(javax.sql.DataSource dataSource)
-
setMaxConnectRetries
public void setMaxConnectRetries(int maxConnectRetries)
-
run
public <T> T run(DatabaseTransaction<T> txn) throws java.lang.Exception
Description copied from interface:TransactionController
Runs a database transaction, i.e. a database connection is aquired and the provided DatabaseTransaction object is executed in the scope of a transaction.- Specified by:
run
in interfaceTransactionController
- Type Parameters:
T
- return type which is passed back by the succeeded transaction. Might be null if transaction runs without giving a result.- Parameters:
txn
- a database transaction object which will be run by the transaction controller.- Returns:
- the result of the transaction if any.
- Throws:
java.lang.Exception
- if something goes wrong within the given transaction which is not caught by itself or if something goes wrong with the transaction management like getConnection throws an SQLException.
-
run
public <T> T run(Transaction<T> txn) throws java.lang.Exception
Description copied from interface:TransactionController
Runs a transaction, the provided DatabaseTransaction object is executed in the scope of a transaction. A database, JMS, or any other connection may be aquired later on in this transaction, but to do so is in the scope of the Transaction object. The TransactionController is just defining the start and end of the transaction.- Specified by:
run
in interfaceTransactionController
- Type Parameters:
T
- return type which is passed back by the succeeded transaction. Might be null if transaction runs without giving a result.- Parameters:
txn
- a database transaction object which will be run by the transaction controller- Returns:
- the result of the transaction if any.
- Throws:
java.lang.Exception
- if something goes wrong within the given transaction which is not caught by itself or if something goes wrong with the transaction management like getConnection throws an SQLException.
-
-