com.github.drinkjava2.jtransactions.tinytx
Class TinyTxConnectionManager

java.lang.Object
  extended by com.github.drinkjava2.jtransactions.tinytx.TinyTxConnectionManager
All Implemented Interfaces:
ConnectionManager

public class TinyTxConnectionManager
extends Object
implements ConnectionManager

DataSourceManager determine how to get or release connection from DataSource, it can be different transaction strategies like JDBC/SpringManaged/JTA..

Since:
1.0.0
Author:
Yong Zhu

Field Summary
static ThreadLocal<Map<DataSource,Connection>> threadLocalConnections
           
 
Constructor Summary
TinyTxConnectionManager()
           
 
Method Summary
 void endTransaction(DataSource ds)
           
 Connection getConnection(DataSource ds)
          A ConnectionManager implementation determine how to get connection from DataSource or ThreadLocal or from Spring or JTA or some container...
static TinyTxConnectionManager instance()
           
 boolean isInTransaction(DataSource ds)
          Check if a connection already be get from given dataSource and be cached as it started a Transaction
 void releaseConnection(Connection conn, DataSource ds)
          A ConnectionManager implementation determine how to close connection or return connection to ThreadLocal or return to Spring or JTA or some container...
 void startTransaction(DataSource ds, Connection conn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threadLocalConnections

public static final ThreadLocal<Map<DataSource,Connection>> threadLocalConnections
Constructor Detail

TinyTxConnectionManager

public TinyTxConnectionManager()
Method Detail

instance

public static final TinyTxConnectionManager instance()
Returns:
A singleton instance of TinyTxConnectionManager

isInTransaction

public boolean isInTransaction(DataSource ds)
Description copied from interface: ConnectionManager
Check if a connection already be get from given dataSource and be cached as it started a Transaction

Specified by:
isInTransaction in interface ConnectionManager

startTransaction

public void startTransaction(DataSource ds,
                             Connection conn)

endTransaction

public void endTransaction(DataSource ds)

getConnection

public Connection getConnection(DataSource ds)
                         throws SQLException
Description copied from interface: ConnectionManager
A ConnectionManager implementation determine how to get connection from DataSource or ThreadLocal or from Spring or JTA or some container...

Specified by:
getConnection in interface ConnectionManager
Throws:
SQLException

releaseConnection

public void releaseConnection(Connection conn,
                              DataSource ds)
                       throws SQLException
Description copied from interface: ConnectionManager
A ConnectionManager implementation determine how to close connection or return connection to ThreadLocal or return to Spring or JTA or some container...

Specified by:
releaseConnection in interface ConnectionManager
Throws:
SQLException


Copyright © 2018. All rights reserved.