public class MapDataSourceLookup extends java.lang.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(java.util.Map<java.lang.String,javax.sql.DataSource> dataSources)
Create a new instance of the
MapDataSourceLookup class. |
MapDataSourceLookup(java.lang.String dataSourceName,
javax.sql.DataSource dataSource)
Create a new instance of the
MapDataSourceLookup class. |
Modifier and Type | Method and Description |
---|---|
void |
addDataSource(java.lang.String dataSourceName,
javax.sql.DataSource dataSource)
Add the supplied
DataSource to the map of DataSources
maintained by this object. |
javax.sql.DataSource |
getDataSource(java.lang.String dataSourceName)
Retrieve the DataSource identified by the given name.
|
java.util.Map<java.lang.String,javax.sql.DataSource> |
getDataSources()
Get the
Map of DataSources maintained by this object. |
void |
setDataSources(java.util.Map<java.lang.String,javax.sql.DataSource> dataSources)
Set the
Map of DataSources ; the keys
are Strings , the values are actual DataSource instances. |
public MapDataSourceLookup()
MapDataSourceLookup
class.public MapDataSourceLookup(java.util.Map<java.lang.String,javax.sql.DataSource> dataSources)
MapDataSourceLookup
class.dataSources
- the Map
of DataSources
; the keys
are Strings
, the values are actual DataSource
instances.public MapDataSourceLookup(java.lang.String dataSourceName, javax.sql.DataSource dataSource)
MapDataSourceLookup
class.dataSourceName
- the name under which the supplied DataSource
is to be addeddataSource
- the DataSource
to be addedpublic void setDataSources(@Nullable java.util.Map<java.lang.String,javax.sql.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 java.util.Map<java.lang.String,javax.sql.DataSource> getDataSources()
Map
of DataSources
maintained by this object.
The returned Map
is unmodifiable
.
Map
of DataSources
(never null
)public void addDataSource(java.lang.String dataSourceName, javax.sql.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 javax.sql.DataSource getDataSource(java.lang.String dataSourceName) throws DataSourceLookupFailureException
DataSourceLookup
getDataSource
in interface DataSourceLookup
dataSourceName
- the name of the DataSourcenull
)DataSourceLookupFailureException
- if the lookup failed