Class MapConnectionFactoryLookup
java.lang.Object
org.springframework.r2dbc.connection.lookup.MapConnectionFactoryLookup
- All Implemented Interfaces:
ConnectionFactoryLookup
Simple
ConnectionFactoryLookup
implementation that relies
on a map for doing lookups.
Useful for testing environments or applications that need to match
arbitrary String
names to target ConnectionFactory
objects.
- Since:
- 5.3
- Author:
- Mark Paluch, Jens Schauder
-
Constructor Summary
ConstructorDescriptionCreate a new instance of theMapConnectionFactoryLookup
class.MapConnectionFactoryLookup
(String connectionFactoryName, ConnectionFactory connectionFactory) Create a new instance of theMapConnectionFactoryLookup
class.MapConnectionFactoryLookup
(Map<String, ConnectionFactory> connectionFactories) Create a new instance of theMapConnectionFactoryLookup
class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionFactory
(String connectionFactoryName, ConnectionFactory connectionFactory) Add the suppliedConnectionFactory
to the map ofConnectionFactory
instances maintained by this object.Get theMap
ofConnectionFactories
maintained by this object.getConnectionFactory
(String connectionFactoryName) Retrieve theConnectionFactory
identified by the given name.void
setConnectionFactories
(Map<String, ConnectionFactory> connectionFactories) Set theMap
ofConnectionFactories
.
-
Constructor Details
-
MapConnectionFactoryLookup
public MapConnectionFactoryLookup()Create a new instance of theMapConnectionFactoryLookup
class. -
MapConnectionFactoryLookup
Create a new instance of theMapConnectionFactoryLookup
class.- Parameters:
connectionFactories
- theMap
ofConnectionFactory
. The keys areStrings
, the values are actualConnectionFactory
instances.
-
MapConnectionFactoryLookup
public MapConnectionFactoryLookup(String connectionFactoryName, ConnectionFactory connectionFactory) Create a new instance of theMapConnectionFactoryLookup
class.- Parameters:
connectionFactoryName
- the name under which the suppliedConnectionFactory
is to be addedconnectionFactory
- theConnectionFactory
to be added
-
-
Method Details
-
setConnectionFactories
Set theMap
ofConnectionFactories
. The keys areStrings
, the values are actualConnectionFactory
instances.If the supplied
Map
isnull
, then this method call effectively has no effect.- Parameters:
connectionFactories
- saidMap
ofconnectionFactories
-
getConnectionFactories
- Returns:
Map
ofconnectionFactory
(nevernull
)
-
addConnectionFactory
Add the suppliedConnectionFactory
to the map ofConnectionFactory
instances maintained by this object.- Parameters:
connectionFactoryName
- the name under which the suppliedConnectionFactory
is to be addedconnectionFactory
- theConnectionFactory
to be so added
-
getConnectionFactory
public ConnectionFactory getConnectionFactory(String connectionFactoryName) throws ConnectionFactoryLookupFailureException Description copied from interface:ConnectionFactoryLookup
Retrieve theConnectionFactory
identified by the given name.- Specified by:
getConnectionFactory
in interfaceConnectionFactoryLookup
- Parameters:
connectionFactoryName
- the name of theConnectionFactory
- Returns:
- the
ConnectionFactory
(nevernull
) - Throws:
ConnectionFactoryLookupFailureException
- if the lookup failed
-