org.kuali.rice.core.database
Class SpringConnectionFactoryManagedImpl
java.lang.Object
org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl
org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl
org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
org.springmodules.orm.ojb.support.LocalDataSourceConnectionFactory
org.kuali.rice.core.database.SpringConnectionFactoryManagedImpl
- All Implemented Interfaces:
- org.apache.ojb.broker.accesslayer.ConnectionFactory
public class SpringConnectionFactoryManagedImpl
- extends org.springmodules.orm.ojb.support.LocalDataSourceConnectionFactory
A subclass of the standard Spring LocalDataSourceConnectionFactory (that supplies
OJB with connections to datasource defined in Spring) that wraps the connection in a
ByPassConnection so that the JTA defined in the managed environment can control the
transaction.
This class works in concert with the following parameter in the corresponding OJB properties
config:
ConnectionFactoryClass=org.kuali.rice.core.database.SpringConnectionFactoryManagedImpl
Apparently this strategy is not required in OJB 1.0.4:
http://db.apache.org/ojb/release-notes.txt
"ConnectionFactoryManagedImpl is declared deprecated. Now OJB automatic detect the
running JTA-transaction and suppress critical method calls on the used connection"
Details:
This is to overcome a shortcoming in Spring/OJB that in 1.03 you can't
run in a managed environment with Spring and OJB if Spring is giving OJB its Connections
through it's LocalDataSourceConnectionFactory (which doesn't wrap the connection in a bypass
connection). This is suppressing commits - so that JTA can do it.
If one uses JNDI to grab the DS this wouldn't be necessary because both
Spring and OJB would grab the DS from there and we'd be cool.
The ByPassConnection is a class that comes with OJB which essentially turns calls
to commit, rollback, etc. into NO-OPS. The reason it does this is because, in a
managed environment these methods are invoked on the individual connections by
the transaction manager and if you call the explicitly from the code they will
typically throw an exception (depending on the JTA implementation).
(what about TransactionAwareDataSourceConnectionFactory mentioned in Spring docs?)
Fields inherited from class org.springmodules.orm.ojb.support.LocalDataSourceConnectionFactory |
beanFactory |
Methods inherited from class org.springmodules.orm.ojb.support.LocalDataSourceConnectionFactory |
getDataSource |
Methods inherited from class org.apache.ojb.broker.accesslayer.ConnectionFactoryNotPooledImpl |
checkOutJdbcConnection, releaseJdbcConnection, validateConnection |
Methods inherited from class org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl |
getDbURL, getJcdDescription, getJdbcProperties, getJdbcProperties, initializeJdbcConnection, newConnectionFromDataSource, releaseAllResources, releaseConnection |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SpringConnectionFactoryManagedImpl
public SpringConnectionFactoryManagedImpl()
lookupConnection
public Connection lookupConnection(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor jcd)
throws org.apache.ojb.broker.accesslayer.LookupException
- Specified by:
lookupConnection
in interface org.apache.ojb.broker.accesslayer.ConnectionFactory
- Overrides:
lookupConnection
in class org.springmodules.orm.ojb.support.LocalDataSourceConnectionFactory
- Throws:
org.apache.ojb.broker.accesslayer.LookupException
newConnectionFromDriverManager
protected Connection newConnectionFromDriverManager(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor arg0)
throws org.apache.ojb.broker.accesslayer.LookupException
- Overrides:
newConnectionFromDriverManager
in class org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
- Throws:
org.apache.ojb.broker.accesslayer.LookupException
Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.