类 MapDataSourceLookup
- java.lang.Object
- org.springframework.jdbc.datasource.lookup.MapDataSourceLookup
- 所有已实现的接口:
DataSourceLookup
public class MapDataSourceLookup extends Object implements DataSourceLookup
SimpleDataSourceLookupimplementation that relies on a map for doing lookups.Useful for testing environments or applications that need to match arbitrary
Stringnames to targetDataSourceobjects.- 从以下版本开始:
- 2.0
- 作者:
- Costin Leau, Juergen Hoeller, Rick Evans
构造器概要
构造器 构造器 说明 MapDataSourceLookup()Create a new instance of theMapDataSourceLookupclass.MapDataSourceLookup(String dataSourceName, DataSource dataSource)Create a new instance of theMapDataSourceLookupclass.MapDataSourceLookup(Map<String,DataSource> dataSources)Create a new instance of theMapDataSourceLookupclass.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidaddDataSource(String dataSourceName, DataSource dataSource)Add the suppliedDataSourceto the map ofDataSourcesmaintained by this object.DataSourcegetDataSource(String dataSourceName)Retrieve the DataSource identified by the given name.Map<String,DataSource>getDataSources()Get theMapofDataSourcesmaintained by this object.voidsetDataSources(Map<String,DataSource> dataSources)
构造器详细资料
MapDataSourceLookup
public MapDataSourceLookup()
Create a new instance of theMapDataSourceLookupclass.
MapDataSourceLookup
public MapDataSourceLookup(Map<String,DataSource> dataSources)
Create a new instance of theMapDataSourceLookupclass.- 参数:
dataSources- theMapofDataSources; the keys areStrings, the values are actualDataSourceinstances.
MapDataSourceLookup
public MapDataSourceLookup(String dataSourceName, DataSource dataSource)
Create a new instance of theMapDataSourceLookupclass.- 参数:
dataSourceName- the name under which the suppliedDataSourceis to be addeddataSource- theDataSourceto be added
方法详细资料
setDataSources
public void setDataSources(@Nullable Map<String,DataSource> dataSources)
Set theMapofDataSources; the keys areStrings, the values are actualDataSourceinstances.If the supplied
Mapisnull, then this method call effectively has no effect.- 参数:
dataSources- saidMapofDataSources
getDataSources
public Map<String,DataSource> getDataSources()
- 返回:
- said
MapofDataSources(nevernull)
addDataSource
public void addDataSource(String dataSourceName, DataSource dataSource)
Add the suppliedDataSourceto the map ofDataSourcesmaintained by this object.- 参数:
dataSourceName- the name under which the suppliedDataSourceis to be addeddataSource- theDataSourceto be so added
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