org.springframework.jca.cci.core.support
Class CciDaoSupport

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.jca.cci.core.support.CciDaoSupport
All Implemented Interfaces:
InitializingBean

public abstract class CciDaoSupport
extends DaoSupport

Convenient super class for CCI-based data access objects.

Requires a ConnectionFactory to be set, providing a CciTemplate based on it to subclasses through the getCciTemplate() method.

This base class is mainly intended for CciTemplate usage but can also be used when working with a Connection directly or when using org.springframework.jca.cci.object classes.

Since:
1.2
Author:
Thierry Templier, Juergen Hoeller
See Also:
setConnectionFactory(javax.resource.cci.ConnectionFactory), getCciTemplate(), CciTemplate

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
CciDaoSupport()
           
 
Method Summary
protected  void checkDaoConfig()
          Abstract subclasses must override this to check their configuration.
protected  CciTemplate createCciTemplate(ConnectionFactory connectionFactory)
          Create a CciTemplate for the given ConnectionFactory.
 CciTemplate getCciTemplate()
          Return the CciTemplate for this DAO, pre-initialized with the ConnectionFactory or set explicitly.
protected  CciTemplate getCciTemplate(ConnectionSpec connectionSpec)
          Obtain a CciTemplate derived from the main template instance, inheriting the ConnectionFactory and other settings but overriding the ConnectionSpec used for obtaining Connections.
protected  Connection getConnection()
          Get a CCI Connection, either from the current transaction or a new one.
 ConnectionFactory getConnectionFactory()
          Return the ConnectionFactory used by this DAO.
protected  void releaseConnection(Connection con)
          Close the given CCI Connection, created via this bean's ConnectionFactory, if it isn't bound to the thread.
 void setCciTemplate(CciTemplate cciTemplate)
          Set the CciTemplate for this DAO explicitly, as an alternative to specifying a ConnectionFactory.
 void setConnectionFactory(ConnectionFactory connectionFactory)
          Set the ConnectionFactory to be used by this DAO.
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CciDaoSupport

public CciDaoSupport()
Method Detail

setConnectionFactory

public final void setConnectionFactory(ConnectionFactory connectionFactory)
Set the ConnectionFactory to be used by this DAO.


createCciTemplate

protected CciTemplate createCciTemplate(ConnectionFactory connectionFactory)
Create a CciTemplate for the given ConnectionFactory. Only invoked if populating the DAO with a ConnectionFactory reference!

Can be overridden in subclasses to provide a CciTemplate instance with different configuration, or a custom CciTemplate subclass.

Parameters:
connectionFactory - the CCI ConnectionFactory to create a CciTemplate for
Returns:
the new CciTemplate instance
See Also:
setConnectionFactory(javax.resource.cci.ConnectionFactory)

getConnectionFactory

public final ConnectionFactory getConnectionFactory()
Return the ConnectionFactory used by this DAO.


setCciTemplate

public final void setCciTemplate(CciTemplate cciTemplate)
Set the CciTemplate for this DAO explicitly, as an alternative to specifying a ConnectionFactory.


getCciTemplate

public final CciTemplate getCciTemplate()
Return the CciTemplate for this DAO, pre-initialized with the ConnectionFactory or set explicitly.


checkDaoConfig

protected final void checkDaoConfig()
Description copied from class: DaoSupport
Abstract subclasses must override this to check their configuration.

Implementors should be marked as final

Specified by:
checkDaoConfig in class DaoSupport

getCciTemplate

protected final CciTemplate getCciTemplate(ConnectionSpec connectionSpec)
Obtain a CciTemplate derived from the main template instance, inheriting the ConnectionFactory and other settings but overriding the ConnectionSpec used for obtaining Connections.

Parameters:
connectionSpec - the CCI ConnectionSpec that the returned template instance is supposed to obtain Connections for
Returns:
the derived template instance
See Also:
CciTemplate.getDerivedTemplate(javax.resource.cci.ConnectionSpec)

getConnection

protected final Connection getConnection()
                                  throws CannotGetCciConnectionException
Get a CCI Connection, either from the current transaction or a new one.

Returns:
the CCI Connection
Throws:
CannotGetCciConnectionException - if the attempt to get a Connection failed
See Also:
ConnectionFactoryUtils.getConnection(javax.resource.cci.ConnectionFactory)

releaseConnection

protected final void releaseConnection(Connection con)
Close the given CCI Connection, created via this bean's ConnectionFactory, if it isn't bound to the thread.

Parameters:
con - Connection to close
See Also:
ConnectionFactoryUtils.releaseConnection(javax.resource.cci.Connection, javax.resource.cci.ConnectionFactory)