站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

LocalDataSourceConnectionFactory (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


org.springframework.orm.ojb.support
Class LocalDataSourceConnectionFactory

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

public class LocalDataSourceConnectionFactory
extends org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl

OJB connection factory that delegates to Spring-managed DataSource beans.

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

 ConnectionFactoryClass=org.springframework.orm.ojb.support.LocalDataSourceConnectionFactory
Interprets JCD aliases in OJB's JDBC connection descriptors as Spring bean names. For example, the following will delegate to the Spring bean named "myDataSource":
 <jdbc-connection-descriptor jcd-alias="myDataSource" default-connection="true" useAutoCommit="1"/>
Depends on LocalOjbConfigurer being defined as Spring bean, which will expose the Spring BeanFactory to the corresponding static field of this connection factory.

Consider using the subclass TransactionAwareDataSourceConnectionFactory instead, to let Spring's OJB access to participate in JDBC-based transactions managed outside of OJB (for example, by Spring's DataSourceTransactionManager), or to automatically apply transaction timeouts managed by PersistenceBrokerTransactionManager.

Since:
1.1
Author:
Juergen Hoeller
See Also:
LocalOjbConfigurer, TransactionAwareDataSourceConnectionFactory

Field Summary
protected static BeanFactory beanFactory
          This will hold the BeanFactory to retrieve DataSource beans from.
 
Constructor Summary
LocalDataSourceConnectionFactory()
           
 
Method Summary
protected  DataSource getDataSource(String jcdAlias)
          Return the DataSource to use for the given JCD alias.
 Connection lookupConnection(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor jcd)
           
 
Methods inherited from class org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
newConnectionFromDriverManager
 
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
 

Field Detail

beanFactory

protected static BeanFactory beanFactory
This will hold the BeanFactory to retrieve DataSource beans from.

Constructor Detail

LocalDataSourceConnectionFactory

public LocalDataSourceConnectionFactory()
Method Detail

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.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl
Throws:
org.apache.ojb.broker.accesslayer.LookupException

getDataSource

protected DataSource getDataSource(String jcdAlias)
Return the DataSource to use for the given JCD alias.

This implementation fetches looks for a bean with the JCD alias name in the provided Spring BeanFactory.

Parameters:
jcdAlias - the JCD alias to retrieve a DataSource for
Returns:
the DataSource to use


Copyright (c) 2002-2007 The Spring Framework Project.