类 MapDataSourceLookup
- java.lang.Object
- org.springframework.jdbc.datasource.lookup.MapDataSourceLookup
- 所有已实现的接口:
DataSourceLookup
public class MapDataSourceLookup extends Object implements DataSourceLookup
SimpleDataSourceLookup
implementation that relies on a map for doing lookups.Useful for testing environments or applications that need to match arbitrary
String
names to targetDataSource
objects.- 从以下版本开始:
- 2.0
- 作者:
- Costin Leau, Juergen Hoeller, Rick Evans
构造器概要
构造器 构造器 说明 MapDataSourceLookup()
Create a new instance of theMapDataSourceLookup
class.MapDataSourceLookup(String dataSourceName, DataSource dataSource)
Create a new instance of theMapDataSourceLookup
class.MapDataSourceLookup(Map<String,DataSource> dataSources)
Create a new instance of theMapDataSourceLookup
class.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addDataSource(String dataSourceName, DataSource dataSource)
Add the suppliedDataSource
to the map ofDataSources
maintained by this object.DataSource
getDataSource(String dataSourceName)
Retrieve the DataSource identified by the given name.Map<String,DataSource>
getDataSources()
Get theMap
ofDataSources
maintained by this object.void
setDataSources(Map<String,DataSource> dataSources)
构造器详细资料
MapDataSourceLookup
public MapDataSourceLookup()
Create a new instance of theMapDataSourceLookup
class.
MapDataSourceLookup
public MapDataSourceLookup(Map<String,DataSource> dataSources)
Create a new instance of theMapDataSourceLookup
class.- 参数:
dataSources
- theMap
ofDataSources
; the keys areStrings
, the values are actualDataSource
instances.
MapDataSourceLookup
public MapDataSourceLookup(String dataSourceName, DataSource dataSource)
Create a new instance of theMapDataSourceLookup
class.- 参数:
dataSourceName
- the name under which the suppliedDataSource
is to be addeddataSource
- theDataSource
to be added
方法详细资料
setDataSources
public void setDataSources(Map<String,DataSource> dataSources)
Set theMap
ofDataSources
; the keys areStrings
, the values are actualDataSource
instances.If the supplied
Map
isnull
, then this method call effectively has no effect.- 参数:
dataSources
- saidMap
ofDataSources
getDataSources
public Map<String,DataSource> getDataSources()
- 返回:
- said
Map
ofDataSources
(nevernull
)
addDataSource
public void addDataSource(String dataSourceName, DataSource dataSource)
Add the suppliedDataSource
to the map ofDataSources
maintained by this object.- 参数:
dataSourceName
- the name under which the suppliedDataSource
is to be addeddataSource
- theDataSource
to be so added
getDataSource
public DataSource getDataSource(String dataSourceName) throws DataSourceLookupFailureException
从接口复制的说明:DataSourceLookup
Retrieve the DataSource identified by the given name.- 指定者:
getDataSource
在接口中DataSourceLookup
- 参数:
dataSourceName
- the name of the DataSource- 返回:
- the DataSource (never
null
) - 抛出:
DataSourceLookupFailureException
- if the lookup failed