org.springframework.orm.ojb.support
Class TransactionAwareDataSourceConnectionFactory

java.lang.Object
  extended byorg.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl
      extended byorg.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl
          extended byorg.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
              extended byorg.springframework.orm.ojb.support.LocalDataSourceConnectionFactory
                  extended byorg.springframework.orm.ojb.support.TransactionAwareDataSourceConnectionFactory
All Implemented Interfaces:
org.apache.ojb.broker.accesslayer.ConnectionFactory

public class TransactionAwareDataSourceConnectionFactory
extends LocalDataSourceConnectionFactory

Subclass of LocalDataSourceConnectionFactory that returns transaction-aware proxies for all DataSources retrieved by OJB.

Define the following entry in your OJB.properties to use this connection factory:

 ConnectionFactoryClass=org.springframework.orm.ojb.support.TransactionAwareDataSourceConnectionFactory
This connection factory allows Spring's OJB access to participate in JDBC-based transactions managed outside of OJB (for example, by Spring's DataSourceTransactionManager). This can be convenient if you need a different local transaction strategy for another O/R mapping tool, for example, but still want OJB access to join into those transactions.

A further benefit of this factory is that plain PersistenceBrokers (opened directly via the PersistenceBrokerFactory, outside of Spring's OJB support) will still participate in active Spring-managed transactions.

As a further effect, using a transaction-aware DataSource will apply remaining transaction timeouts to all created JDBC Statements. This means that all operations performed by OJB will automatically participate in Spring-managed transaction timeouts. This is even desirable for transactions managed by PersistenceBrokerTransactionManager.

Since:
1.1.4
Author:
Juergen Hoeller
See Also:
TransactionAwareDataSourceProxy, DataSourceTransactionManager, PersistenceBrokerTransactionManager

Field Summary
 
Fields inherited from class org.springframework.orm.ojb.support.LocalDataSourceConnectionFactory
beanFactory
 
Constructor Summary
TransactionAwareDataSourceConnectionFactory()
           
 
Method Summary
protected  DataSource getDataSource(String jcdAlias)
          Return a TransactionAwareDataSourceProxy for the original DataSource (i.e. the Spring bean with the JCD alias name), provided that it isn't a TransactionAwareDataSourceProxy already.
 
Methods inherited from class org.springframework.orm.ojb.support.LocalDataSourceConnectionFactory
lookupConnection
 
Methods inherited from class org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
newConnectionFromDriverManager
 
Methods inherited from class org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl
getConnectionFromPool, returnConnectionToPool
 
Methods inherited from class org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl
getDbURL, initializeJdbcConnection, newConnectionFromDataSource, releaseAllResources, releaseConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionAwareDataSourceConnectionFactory

public TransactionAwareDataSourceConnectionFactory()
Method Detail

getDataSource

protected DataSource getDataSource(String jcdAlias)
Return a TransactionAwareDataSourceProxy for the original DataSource (i.e. the Spring bean with the JCD alias name), provided that it isn't a TransactionAwareDataSourceProxy already.

Overrides:
getDataSource in class LocalDataSourceConnectionFactory
Parameters:
jcdAlias - the JCD alias to retrieve a DataSource for
Returns:
the DataSource to use


Copyright (C) 2003-2004 The Spring Framework Project.