Class BeanFactoryDataSourceLookup
java.lang.Object
org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- DataSourceLookup
public class BeanFactoryDataSourceLookup
extends Object
implements DataSourceLookup, BeanFactoryAware
DataSourceLookup implementation based on a Spring BeanFactory.
 Will lookup Spring managed beans identified by bean name,
 expecting them to be of type javax.sql.DataSource.
- Since:
- 2.0
- Author:
- Costin Leau, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a new instance of theBeanFactoryDataSourceLookupclass.BeanFactoryDataSourceLookup(BeanFactory beanFactory) Create a new instance of theBeanFactoryDataSourceLookupclass.
- 
Method SummaryModifier and TypeMethodDescriptiongetDataSource(String dataSourceName) Retrieve the DataSource identified by the given name.voidsetBeanFactory(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.
- 
Constructor Details- 
BeanFactoryDataSourceLookuppublic BeanFactoryDataSourceLookup()Create a new instance of theBeanFactoryDataSourceLookupclass.The BeanFactory to access must be set via setBeanFactory.
- 
BeanFactoryDataSourceLookupCreate 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.- Parameters:
- beanFactory- the bean factory to be used to lookup- DataSources
 
 
- 
- 
Method Details- 
setBeanFactoryDescription copied from interface: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.- Specified by:
- setBeanFactoryin interface- BeanFactoryAware
- Parameters:
- beanFactory- owning BeanFactory (never- null). The bean can immediately call methods on the factory.
- See Also:
 
- 
getDataSourceDescription copied from interface:DataSourceLookupRetrieve the DataSource identified by the given name.- Specified by:
- getDataSourcein interface- DataSourceLookup
- Parameters:
- dataSourceName- the name of the DataSource
- Returns:
- the DataSource (never null)
- Throws:
- DataSourceLookupFailureException- if the lookup failed
 
 
-