public class

MapDataSourceLookup

extends Object
implements DataSourceLookup
java.lang.Object
   ↳ org.springframework.jdbc.datasource.lookup.MapDataSourceLookup

Class Overview

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.

Summary

Public Constructors
MapDataSourceLookup()
Create a new instance of the MapDataSourceLookup class.
MapDataSourceLookup(Map<StringDataSource> dataSources)
Create a new instance of the MapDataSourceLookup class.
MapDataSourceLookup(String dataSourceName, DataSource dataSource)
Create a new instance of the MapDataSourceLookup class.
Public Methods
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<StringDataSource> getDataSources()
Get the Map of DataSources maintained by this object.
void setDataSources(Map<StringDataSource> dataSources)
Set the Map of DataSources; the keys are Strings, the values are actual DataSource instances.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.jdbc.datasource.lookup.DataSourceLookup

Public Constructors

public MapDataSourceLookup ()

Create a new instance of the MapDataSourceLookup class.

public MapDataSourceLookup (Map<StringDataSource> dataSources)

Create a new instance of the MapDataSourceLookup class.

Parameters
dataSources the Map of DataSources; the keys are Strings, the values are actual DataSource instances.

public MapDataSourceLookup (String dataSourceName, DataSource dataSource)

Create a new instance of the MapDataSourceLookup class.

Parameters
dataSourceName the name under which the supplied DataSource is to be added
dataSource the DataSource to be added

Public Methods

public void addDataSource (String dataSourceName, DataSource dataSource)

Add the supplied DataSource to the map of DataSources maintained by this object.

Parameters
dataSourceName the name under which the supplied DataSource is to be added
dataSource the DataSource to be so added

public DataSource getDataSource (String dataSourceName)

Retrieve the DataSource identified by the given name.

Parameters
dataSourceName the name of the DataSource
Returns
  • the DataSource (never null)

public Map<StringDataSource> getDataSources ()

Get the Map of DataSources maintained by this object.

The returned Map is unmodifiable.

Returns

public void setDataSources (Map<StringDataSource> dataSources)

Set the 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.

Parameters
dataSources said Map of DataSources