类 BeanFactoryDataSourceLookup
- java.lang.Object
- org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup
- 所有已实现的接口:
Aware,BeanFactoryAware,DataSourceLookup
public class BeanFactoryDataSourceLookup extends Object implements DataSourceLookup, BeanFactoryAware
DataSourceLookupimplementation based on a SpringBeanFactory.Will lookup Spring managed beans identified by bean name, expecting them to be of type
javax.sql.DataSource.- 从以下版本开始:
- 2.0
- 作者:
- Costin Leau, Juergen Hoeller
- 另请参阅:
BeanFactory
构造器概要
构造器 构造器 说明 BeanFactoryDataSourceLookup()Create a new instance of theBeanFactoryDataSourceLookupclass.BeanFactoryDataSourceLookup(BeanFactory beanFactory)Create a new instance of theBeanFactoryDataSourceLookupclass.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 DataSourcegetDataSource(String dataSourceName)Retrieve the DataSource identified by the given name.voidsetBeanFactory(BeanFactory beanFactory)Callback that supplies the owning factory to a bean instance.
构造器详细资料
BeanFactoryDataSourceLookup
public BeanFactoryDataSourceLookup()
Create a new instance of theBeanFactoryDataSourceLookupclass.The BeanFactory to access must be set via
setBeanFactory.
BeanFactoryDataSourceLookup
public BeanFactoryDataSourceLookup(BeanFactory beanFactory)
Create a new instance of theBeanFactoryDataSourceLookupclass.Use of this constructor is redundant if this object is being created by a Spring IoC container, as the supplied
BeanFactorywill be replaced by theBeanFactorythat creates it (c.f. theBeanFactoryAwarecontract). So only use this constructor if you are using this class outside the context of a Spring IoC container.- 参数:
beanFactory- the bean factory to be used to lookupDataSources
方法详细资料
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
从接口复制的说明:BeanFactoryAwareCallback that supplies the owning factory to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()or a custom init-method.- 指定者:
setBeanFactory在接口中BeanFactoryAware- 参数:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- 另请参阅:
BeanInitializationException
getDataSource
public DataSource getDataSource(String dataSourceName) throws DataSourceLookupFailureException
从接口复制的说明:DataSourceLookupRetrieve the DataSource identified by the given name.- 指定者:
getDataSource在接口中DataSourceLookup- 参数:
dataSourceName- the name of the DataSource- 返回:
- the DataSource (never
null) - 抛出:
DataSourceLookupFailureException- if the lookup failed