Class MapDataSourceLookup
java.lang.Object
org.springframework.jdbc.datasource.lookup.MapDataSourceLookup
- All Implemented Interfaces:
- DataSourceLookup
Simple 
DataSourceLookup implementation that relies on a map for doing lookups.
 Useful for testing environments or applications that need to match arbitrary
 String names to target DataSource objects.
- Since:
- 2.0
- Author:
- Costin Leau, Juergen Hoeller, Rick Evans
- 
Constructor SummaryConstructorsConstructorDescriptionCreate 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.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddDataSource(String dataSourceName, DataSource dataSource) Add the suppliedDataSourceto the map ofDataSourcesmaintained by this object.getDataSource(String dataSourceName) Retrieve the DataSource identified by the given name.Get theMapofDataSourcesmaintained by this object.voidsetDataSources(Map<String, DataSource> dataSources) 
- 
Constructor Details- 
MapDataSourceLookuppublic MapDataSourceLookup()Create a new instance of theMapDataSourceLookupclass.
- 
MapDataSourceLookupCreate a new instance of theMapDataSourceLookupclass.- Parameters:
- dataSources- the- Mapof- DataSources; the keys are- Strings, the values are actual- DataSourceinstances.
 
- 
MapDataSourceLookupCreate a new instance of theMapDataSourceLookupclass.- Parameters:
- dataSourceName- the name under which the supplied- DataSourceis to be added
- dataSource- the- DataSourceto be added
 
 
- 
- 
Method Details- 
setDataSourcesSet theMapofDataSources; the keys areStrings, the values are actualDataSourceinstances.If the supplied Mapisnull, then this method call effectively has no effect.- Parameters:
- dataSources- said- Mapof- DataSources
 
- 
getDataSources- Returns:
- said MapofDataSources(nevernull)
 
- 
addDataSourceAdd the suppliedDataSourceto the map ofDataSourcesmaintained by this object.- Parameters:
- dataSourceName- the name under which the supplied- DataSourceis to be added
- dataSource- the- DataSourceto be so added
 
- 
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
 
 
-