类 ConnectionFactoryUtils
- java.lang.Object
- org.springframework.jca.cci.connection.ConnectionFactoryUtils
public abstract class ConnectionFactoryUtils extends Object
Helper class that provides static methods for obtaining CCI Connections from aConnectionFactory
. Includes special support for Spring-managed transactional Connections, e.g. managed byCciLocalTransactionManager
orJtaTransactionManager
.Used internally by
CciTemplate
, Spring's CCI operation objects and theCciLocalTransactionManager
. Can also be used directly in application code.- 从以下版本开始:
- 1.2
- 作者:
- Thierry Templier, Juergen Hoeller
- 另请参阅:
getConnection(javax.resource.cci.ConnectionFactory)
,releaseConnection(javax.resource.cci.Connection, javax.resource.cci.ConnectionFactory)
,CciLocalTransactionManager
,JtaTransactionManager
,TransactionSynchronizationManager
构造器概要
构造器 构造器 说明 ConnectionFactoryUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static Connection
doGetConnection(ConnectionFactory cf)
Actually obtain a CCI Connection from the given ConnectionFactory.static void
doReleaseConnection(Connection con, ConnectionFactory cf)
Actually close the given Connection, obtained from the given ConnectionFactory.static Connection
getConnection(ConnectionFactory cf)
Obtain a Connection from the given ConnectionFactory.static Connection
getConnection(ConnectionFactory cf, ConnectionSpec spec)
Obtain a Connection from the given ConnectionFactory.static boolean
isConnectionTransactional(Connection con, ConnectionFactory cf)
Determine whether the given JCA CCI Connection is transactional, that is, bound to the current thread by Spring's transaction facilities.static void
releaseConnection(Connection con, ConnectionFactory cf)
Close the given Connection, obtained from the given ConnectionFactory, if it is not managed externally (that is, not bound to the thread).
构造器详细资料
ConnectionFactoryUtils
public ConnectionFactoryUtils()
方法详细资料
getConnection
public static Connection getConnection(ConnectionFactory cf) throws CannotGetCciConnectionException
Obtain a Connection from the given ConnectionFactory. Translates ResourceExceptions into the Spring hierarchy of unchecked generic data access exceptions, simplifying calling code and making any exception that is thrown more meaningful.Is aware of a corresponding Connection bound to the current thread, for example when using
CciLocalTransactionManager
. Will bind a Connection to the thread if transaction synchronization is active (e.g. if in a JTA transaction).- 参数:
cf
- the ConnectionFactory to obtain Connection from- 返回:
- a CCI Connection from the given ConnectionFactory
- 抛出:
CannotGetCciConnectionException
- if the attempt to get a Connection failed- 另请参阅:
releaseConnection(javax.resource.cci.Connection, javax.resource.cci.ConnectionFactory)
getConnection
public static Connection getConnection(ConnectionFactory cf, ConnectionSpec spec) throws CannotGetCciConnectionException
Obtain a Connection from the given ConnectionFactory. Translates ResourceExceptions into the Spring hierarchy of unchecked generic data access exceptions, simplifying calling code and making any exception that is thrown more meaningful.Is aware of a corresponding Connection bound to the current thread, for example when using
CciLocalTransactionManager
. Will bind a Connection to the thread if transaction synchronization is active (e.g. if in a JTA transaction).- 参数:
cf
- the ConnectionFactory to obtain Connection fromspec
- the ConnectionSpec for the desired Connection (may benull
). Note: If this is specified, a new Connection will be obtained for every call, without participating in a shared transactional Connection.- 返回:
- a CCI Connection from the given ConnectionFactory
- 抛出:
CannotGetCciConnectionException
- if the attempt to get a Connection failed- 另请参阅:
releaseConnection(javax.resource.cci.Connection, javax.resource.cci.ConnectionFactory)
doGetConnection
public static Connection doGetConnection(ConnectionFactory cf) throws ResourceException
Actually obtain a CCI Connection from the given ConnectionFactory. Same asgetConnection(javax.resource.cci.ConnectionFactory)
, but throwing the original ResourceException.Is aware of a corresponding Connection bound to the current thread, for example when using
CciLocalTransactionManager
. Will bind a Connection to the thread if transaction synchronization is active (e.g. if in a JTA transaction).Directly accessed by
TransactionAwareConnectionFactoryProxy
.- 参数:
cf
- the ConnectionFactory to obtain Connection from- 返回:
- a CCI Connection from the given ConnectionFactory
- 抛出:
ResourceException
- if thrown by CCI API methods- 另请参阅:
doReleaseConnection(javax.resource.cci.Connection, javax.resource.cci.ConnectionFactory)
isConnectionTransactional
public static boolean isConnectionTransactional(Connection con, ConnectionFactory cf)
Determine whether the given JCA CCI Connection is transactional, that is, bound to the current thread by Spring's transaction facilities.- 参数:
con
- the Connection to checkcf
- the ConnectionFactory that the Connection was obtained from (may benull
)- 返回:
- whether the Connection is transactional
releaseConnection
public static void releaseConnection(Connection con, ConnectionFactory cf)
Close the given Connection, obtained from the given ConnectionFactory, if it is not managed externally (that is, not bound to the thread).- 参数:
con
- the Connection to close if necessary (if this isnull
, the call will be ignored)cf
- the ConnectionFactory that the Connection was obtained from (can benull
)- 另请参阅:
getConnection(javax.resource.cci.ConnectionFactory)
doReleaseConnection
public static void doReleaseConnection(Connection con, ConnectionFactory cf) throws ResourceException
Actually close the given Connection, obtained from the given ConnectionFactory. Same asreleaseConnection(javax.resource.cci.Connection, javax.resource.cci.ConnectionFactory)
, but throwing the original ResourceException.Directly accessed by
TransactionAwareConnectionFactoryProxy
.- 参数:
con
- the Connection to close if necessary (if this isnull
, the call will be ignored)cf
- the ConnectionFactory that the Connection was obtained from (can benull
)- 抛出:
ResourceException
- if thrown by JCA CCI methods- 另请参阅:
doGetConnection(javax.resource.cci.ConnectionFactory)