Package network.oxalis.persistence.aop
Class JdbcTxManagerImpl
- java.lang.Object
-
- network.oxalis.persistence.aop.JdbcTxManagerImpl
-
- All Implemented Interfaces:
JdbcTxManager
public class JdbcTxManagerImpl extends Object implements JdbcTxManager
Implementation of a transaction manager, which is responsible for handling a Connection object which is placed into ThreadLocal.It is responsible for fetching Connection objects from a DataSource, and setting them up so that they can be transactional (autoCommit --> false).
It also can be used to rollback programatically an existing transaction.
-
-
Constructor Summary
Constructors Constructor Description JdbcTxManagerImpl(DataSource dataSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Closes the connection and removes the connection from the thread localvoidcommit()Commits the current connection Requires that the existing connection was created with autocommit set to false.ConnectiongetConnection()Gets the connectionbooleanisConnection()Checks if the current connection is null.booleanisTransaction()Checks whether the current connection is not null and autocomit is set to false.voidnewConnection(boolean autoCommit)N.B.voidrollback()Rollbacks the current connectionvoidsetRollbackOnly()marks the transaction to be rollbackedvoidtrace(String message)logs a debug message with the current transaction object
-
-
-
Constructor Detail
-
JdbcTxManagerImpl
@Inject public JdbcTxManagerImpl(DataSource dataSource)
-
-
Method Detail
-
isTransaction
public boolean isTransaction()
Description copied from interface:JdbcTxManagerChecks whether the current connection is not null and autocomit is set to false.- Specified by:
isTransactionin interfaceJdbcTxManager- Returns:
-
isConnection
public boolean isConnection()
Description copied from interface:JdbcTxManagerChecks if the current connection is null.- Specified by:
isConnectionin interfaceJdbcTxManager- Returns:
-
newConnection
public void newConnection(boolean autoCommit)
Description copied from interface:JdbcTxManagerN.B. DO NOT USE THIS METHOD DIRECTLY. It is only to be used by the TransactionalMethodInterceptor and the RepositoryConnectionMethodInterceptor Makes a Connection object available from the getConnection() method with either autocomit set to true or false.- Specified by:
newConnectionin interfaceJdbcTxManager- Parameters:
autoCommit- automatically commits after each execute. Set to false to use transactions.
-
commit
public void commit()
Description copied from interface:JdbcTxManagerCommits the current connection Requires that the existing connection was created with autocommit set to false.- Specified by:
commitin interfaceJdbcTxManager
-
rollback
public void rollback()
Description copied from interface:JdbcTxManagerRollbacks the current connection- Specified by:
rollbackin interfaceJdbcTxManager
-
cleanUp
public void cleanUp()
Description copied from interface:JdbcTxManagerCloses the connection and removes the connection from the thread local- Specified by:
cleanUpin interfaceJdbcTxManager
-
getConnection
public Connection getConnection()
Gets the connection- Specified by:
getConnectionin interfaceJdbcTxManager- Returns:
-
setRollbackOnly
public void setRollbackOnly()
marks the transaction to be rollbacked- Specified by:
setRollbackOnlyin interfaceJdbcTxManager
-
trace
public void trace(String message)
logs a debug message with the current transaction object- Specified by:
tracein interfaceJdbcTxManager- Parameters:
message-
-
-