public class MapDataSourceLookup extends Object implements DataSourceLookup
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.
Constructor and Description |
---|
MapDataSourceLookup()
Create a new instance of the
MapDataSourceLookup class. |
MapDataSourceLookup(Map<String,DataSource> dataSources)
Create a new instance of the
MapDataSourceLookup class. |
MapDataSourceLookup(String dataSourceName,
DataSource dataSource)
Create a new instance of the
MapDataSourceLookup class. |
Modifier and Type | Method and Description |
---|---|
void |
addDataSource(String dataSourceName,
DataSource dataSource)
Add the supplied
DataSource to the map of DataSources
maintained by this object. |
DataSource |
getDataSource(String dataSourceName)
Retrieve the DataSource identified by the given name.
|
Map<String,DataSource> |
getDataSources()
Get the
Map of DataSources maintained by this object. |
void |
setDataSources(Map<String,DataSource> dataSources)
|
public MapDataSourceLookup()
MapDataSourceLookup
class.public MapDataSourceLookup(Map<String,DataSource> dataSources)
MapDataSourceLookup
class.dataSources
- the Map
of DataSources
; the keys
are Strings
, the values are actual DataSource
instances.public MapDataSourceLookup(String dataSourceName, DataSource dataSource)
MapDataSourceLookup
class.dataSourceName
- the name under which the supplied DataSource
is to be addeddataSource
- the DataSource
to be addedpublic void setDataSources(Map<String,DataSource> dataSources)
Map
of DataSources
; the keys
are Strings
, the values are actual DataSource
instances.
If the supplied Map
is null
, then this method
call effectively has no effect.
dataSources
- said Map
of DataSources
public Map<String,DataSource> getDataSources()
Map
of DataSources
(never null
)public void addDataSource(String dataSourceName, DataSource dataSource)
DataSource
to the map of DataSources
maintained by this object.dataSourceName
- the name under which the supplied DataSource
is to be addeddataSource
- the DataSource
to be so addedpublic DataSource getDataSource(String dataSourceName) throws DataSourceLookupFailureException
DataSourceLookup
getDataSource
in interface DataSourceLookup
dataSourceName
- the name of the DataSourcenull
)DataSourceLookupFailureException
- if the lookup failed