类 SingleConnectionFactory
- java.lang.Object
- org.springframework.jca.cci.connection.DelegatingConnectionFactory
- org.springframework.jca.cci.connection.SingleConnectionFactory
- 所有已实现的接口:
Serializable
,Referenceable
,ConnectionFactory
,Referenceable
,DisposableBean
,InitializingBean
public class SingleConnectionFactory extends DelegatingConnectionFactory implements DisposableBean
A CCI ConnectionFactory adapter that returns the same Connection on allgetConnection
calls, and ignores calls toConnection.close()
.Useful for testing and standalone environments, to keep using the same Connection for multiple CciTemplate calls, without having a pooling ConnectionFactory, also spanning any number of transactions.
You can either pass in a CCI Connection directly, or let this factory lazily create a Connection via a given target ConnectionFactory.
- 从以下版本开始:
- 1.2
- 作者:
- Juergen Hoeller
- 另请参阅:
getConnection()
,Connection.close()
,CciTemplate
, 序列化表格
构造器概要
构造器 构造器 说明 SingleConnectionFactory()
Create a new SingleConnectionFactory for bean-style usage.SingleConnectionFactory(Connection target)
Create a new SingleConnectionFactory that always returns the given Connection.SingleConnectionFactory(ConnectionFactory targetConnectionFactory)
Create a new SingleConnectionFactory that always returns a single Connection which it will lazily create via the given target ConnectionFactory.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Make sure a Connection or ConnectionFactory has been set.protected void
closeConnection(Connection con)
Close the given Connection.void
destroy()
Close the underlying Connection.protected Connection
doCreateConnection()
Create a CCI Connection via this template's ConnectionFactory.protected Connection
getCloseSuppressingConnectionProxy(Connection target)
Wrap the given Connection with a proxy that delegates every method call to it but suppresses close calls.Connection
getConnection()
Connection
getConnection(ConnectionSpec connectionSpec)
void
initConnection()
Initialize the single underlying Connection.protected void
prepareConnection(Connection con)
Prepare the given Connection before it is exposed.void
resetConnection()
Reset the underlying shared Connection, to be reinitialized on next access.从类继承的方法 org.springframework.jca.cci.connection.DelegatingConnectionFactory
getMetaData, getRecordFactory, getReference, getTargetConnectionFactory, obtainTargetConnectionFactory, setReference, setTargetConnectionFactory
构造器详细资料
SingleConnectionFactory
public SingleConnectionFactory()
Create a new SingleConnectionFactory for bean-style usage.
SingleConnectionFactory
public SingleConnectionFactory(Connection target)
Create a new SingleConnectionFactory that always returns the given Connection.- 参数:
target
- the single Connection
SingleConnectionFactory
public SingleConnectionFactory(ConnectionFactory targetConnectionFactory)
Create a new SingleConnectionFactory that always returns a single Connection which it will lazily create via the given target ConnectionFactory.- 参数:
targetConnectionFactory
- the target ConnectionFactory
方法详细资料
afterPropertiesSet
public void afterPropertiesSet()
Make sure a Connection or ConnectionFactory has been set.
getConnection
public Connection getConnection() throws ResourceException
getConnection
public Connection getConnection(ConnectionSpec connectionSpec) throws ResourceException
destroy
public void destroy()
Close the underlying Connection. The provider of this ConnectionFactory needs to care for proper shutdown.As this bean implements DisposableBean, a bean factory will automatically invoke this on destruction of its cached singletons.
- 指定者:
destroy
在接口中DisposableBean
initConnection
public void initConnection() throws ResourceException
Initialize the single underlying Connection.Closes and reinitializes the Connection if an underlying Connection is present already.
- 抛出:
ResourceException
- if thrown by CCI API methods
resetConnection
public void resetConnection()
Reset the underlying shared Connection, to be reinitialized on next access.
doCreateConnection
protected Connection doCreateConnection() throws ResourceException
Create a CCI Connection via this template's ConnectionFactory.- 返回:
- the new CCI Connection
- 抛出:
ResourceException
- if thrown by CCI API methods
prepareConnection
protected void prepareConnection(Connection con) throws ResourceException
Prepare the given Connection before it is exposed.The default implementation is empty. Can be overridden in subclasses.
- 参数:
con
- the Connection to prepare- 抛出:
ResourceException
closeConnection
protected void closeConnection(Connection con)
Close the given Connection.- 参数:
con
- the Connection to close
getCloseSuppressingConnectionProxy
protected Connection getCloseSuppressingConnectionProxy(Connection target)
Wrap the given Connection with a proxy that delegates every method call to it but suppresses close calls. This is useful for allowing application code to handle a special framework Connection just like an ordinary Connection from a CCI ConnectionFactory.- 参数:
target
- the original Connection to wrap- 返回:
- the wrapped Connection