类 TransactionAwareConnectionFactoryProxy
- java.lang.Object
- org.springframework.jca.cci.connection.DelegatingConnectionFactory
- org.springframework.jca.cci.connection.TransactionAwareConnectionFactoryProxy
public class TransactionAwareConnectionFactoryProxy extends DelegatingConnectionFactory
Proxy for a target CCIConnectionFactory
, adding awareness of Spring-managed transactions. Similar to a transactional JNDI ConnectionFactory as provided by a J2EE server.Data access code that should remain unaware of Spring's data access support can work with this proxy to seamlessly participate in Spring-managed transactions. Note that the transaction manager, for example the
CciLocalTransactionManager
, still needs to work with underlying ConnectionFactory, not with this proxy.Make sure that TransactionAwareConnectionFactoryProxy is the outermost ConnectionFactory of a chain of ConnectionFactory proxies/adapters. TransactionAwareConnectionFactoryProxy can delegate either directly to the target connection pool or to some intermediate proxy/adapter like
ConnectionSpecConnectionFactoryAdapter
.Delegates to
ConnectionFactoryUtils
for automatically participating in thread-bound transactions, for example managed byCciLocalTransactionManager
.getConnection
calls andclose
calls on returned Connections will behave properly within a transaction, i.e. always operate on the transactional Connection. If not within a transaction, normal ConnectionFactory behavior applies.This proxy allows data access code to work with the plain JCA CCI API and still participate in Spring-managed transactions, similar to CCI code in a J2EE/JTA environment. However, if possible, use Spring's ConnectionFactoryUtils, CciTemplate or CCI operation objects to get transaction participation even without a proxy for the target ConnectionFactory, avoiding the need to define such a proxy in the first place.
NOTE: This ConnectionFactory proxy needs to return wrapped Connections in order to handle close calls properly. Therefore, the returned Connections cannot be cast to a native CCI Connection type or to a connection pool implementation type.
构造器概要
构造器 构造器 说明 TransactionAwareConnectionFactoryProxy()
Create a new TransactionAwareConnectionFactoryProxy.TransactionAwareConnectionFactoryProxy(ConnectionFactory targetConnectionFactory)
Create a new TransactionAwareConnectionFactoryProxy.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Connection
getConnection()
Delegate to ConnectionFactoryUtils for automatically participating in Spring-managed transactions.protected Connection
getTransactionAwareConnectionProxy(Connection target, ConnectionFactory cf)
Wrap the given Connection with a proxy that delegates every method call to it but delegatesclose
calls to ConnectionFactoryUtils.从类继承的方法 org.springframework.jca.cci.connection.DelegatingConnectionFactory
afterPropertiesSet, getConnection, getMetaData, getRecordFactory, getReference, getTargetConnectionFactory, setReference, setTargetConnectionFactory
构造器详细资料
TransactionAwareConnectionFactoryProxy
public TransactionAwareConnectionFactoryProxy()
Create a new TransactionAwareConnectionFactoryProxy.
TransactionAwareConnectionFactoryProxy
public TransactionAwareConnectionFactoryProxy(ConnectionFactory targetConnectionFactory)
Create a new TransactionAwareConnectionFactoryProxy.- 参数:
targetConnectionFactory
- the target ConnectionFactory
方法详细资料
getConnection
public Connection getConnection() throws ResourceException
Delegate to ConnectionFactoryUtils for automatically participating in Spring-managed transactions. Throws the original ResourceException, if any.- 指定者:
getConnection
在接口中ConnectionFactory
- 覆盖:
getConnection
在类中DelegatingConnectionFactory
- 返回:
- a transactional Connection if any, a new one else
- 抛出:
ResourceException
- 另请参阅:
ConnectionFactoryUtils.doGetConnection(javax.resource.cci.ConnectionFactory)
getTransactionAwareConnectionProxy
protected Connection getTransactionAwareConnectionProxy(Connection target, ConnectionFactory cf)
Wrap the given Connection with a proxy that delegates every method call to it but delegatesclose
calls to ConnectionFactoryUtils.- 参数:
target
- the original Connection to wrapcf
- ConnectionFactory that the Connection came from- 返回:
- the wrapped Connection
- 另请参阅:
Connection.close()
,ConnectionFactoryUtils.doReleaseConnection(javax.resource.cci.Connection, javax.resource.cci.ConnectionFactory)