net.sourceforge.hivetranse.transaction.jdbc
Class ConnectionsRepositoryImpl

java.lang.Object
  extended by net.sourceforge.hivetranse.transaction.jdbc.ConnectionsRepositoryImpl
All Implemented Interfaces:
ConnectionsRepository

public class ConnectionsRepositoryImpl
extends java.lang.Object
implements ConnectionsRepository

Actual implementation class for ConnectionsRepository. Enlisted connections are stored in a Map.

Author:
Jean-Francois Poilpret

Constructor Summary
ConnectionsRepositoryImpl()
           
 
Method Summary
protected  java.sql.SQLException closeConnection(java.lang.String id, java.sql.Connection cnx)
           
 void endAllConnections(boolean close, boolean commit)
          Terminate all connections enlisted in the current transaction.
 java.sql.Connection getConnection(java.lang.String id, javax.sql.DataSource ds)
          Get a Connection by its id for the current transaction (in the current thread).
protected  java.sql.SQLException terminateConnection(java.lang.String id, java.sql.Connection cnx, boolean commit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionsRepositoryImpl

public ConnectionsRepositoryImpl()
Method Detail

getConnection

public java.sql.Connection getConnection(java.lang.String id,
                                         javax.sql.DataSource ds)
                                  throws java.sql.SQLException
Description copied from interface: ConnectionsRepository
Get a Connection by its id for the current transaction (in the current thread). If this connection does not exist yet then it is created by the underlying DataSource and it is "enlisted" into the current transaction.

Specified by:
getConnection in interface ConnectionsRepository
Parameters:
id - unique identifier of the Connection
ds - DataSource to be used to create new Connection if needed
Returns:
the connection for this id and the current transaction
Throws:
java.sql.SQLException

endAllConnections

public void endAllConnections(boolean close,
                              boolean commit)
                       throws java.sql.SQLException
Description copied from interface: ConnectionsRepository
Terminate all connections enlisted in the current transaction. Used only by JdbcTransactionService.

Specified by:
endAllConnections in interface ConnectionsRepository
Parameters:
close - true if connections should be closed immediately or not
commit - true if all connections should be committed before closing, false if they should be rolled back
Throws:
java.sql.SQLException

terminateConnection

protected java.sql.SQLException terminateConnection(java.lang.String id,
                                                    java.sql.Connection cnx,
                                                    boolean commit)

closeConnection

protected java.sql.SQLException closeConnection(java.lang.String id,
                                                java.sql.Connection cnx)