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 <code>String</code> names to target <code>DataSource</code> objects.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,javax.sql.DataSource> |
dataSources |
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 <code>DataSource</code> to the map of <code>DataSources</code>
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 <code>Map</code> of <code>DataSources</code> maintained by this object.
|
void |
setDataSources(java.util.Map<java.lang.String,javax.sql.DataSource> dataSources)
Set the <code>Map</code> of <code>DataSources</code>; the keys
are <code>Strings</code>, the values are actual <code>DataSource</code> instances.
|
private final java.util.Map<java.lang.String,javax.sql.DataSource> dataSources
public MapDataSourceLookup()
MapDataSourceLookup
class.public MapDataSourceLookup(java.util.Map<java.lang.String,javax.sql.DataSource> dataSources)
MapDataSourceLookup
class.dataSources
- the <code>Map</code> of <code>DataSources</code>; the keys
are <code>Strings</code>, the values are actual <code>DataSource</code> instances.public MapDataSourceLookup(java.lang.String dataSourceName, javax.sql.DataSource dataSource)
MapDataSourceLookup
class.dataSourceName
- the name under which the supplied <code>DataSource</code> is to be addeddataSource
- the <code>DataSource</code> to be addedpublic void setDataSources(java.util.Map<java.lang.String,javax.sql.DataSource> dataSources)
If the supplied <code>Map</code> is null
, then this method
call effectively has no effect.
dataSources
- said <code>Map</code> of <code>DataSources</code>public java.util.Map<java.lang.String,javax.sql.DataSource> getDataSources()
The returned <code>Map</code> is unmodifiable
.
null
)public void addDataSource(java.lang.String dataSourceName, javax.sql.DataSource dataSource)
dataSourceName
- the name under which the supplied <code>DataSource</code> is to be addeddataSource
- the <code>DataSource</code> 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