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
ConstructorsConstructorDescriptionCreate a new instance of theMapConnectionFactoryLookupclass.MapConnectionFactoryLookup(String connectionFactoryName, ConnectionFactory connectionFactory) Create a new instance of theMapConnectionFactoryLookupclass.MapConnectionFactoryLookup(Map<String, ConnectionFactory> connectionFactories) Create a new instance of theMapConnectionFactoryLookupclass. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnectionFactory(String connectionFactoryName, ConnectionFactory connectionFactory) Add the suppliedConnectionFactoryto the map ofConnectionFactoryinstances maintained by this object.Get theMapofConnectionFactoriesmaintained by this object.getConnectionFactory(String connectionFactoryName) Retrieve theConnectionFactoryidentified by the given name.voidsetConnectionFactories(Map<String, ConnectionFactory> connectionFactories) Set theMapofConnectionFactories.
-
Constructor Details
-
MapConnectionFactoryLookup
public MapConnectionFactoryLookup()Create a new instance of theMapConnectionFactoryLookupclass. -
MapConnectionFactoryLookup
Create a new instance of theMapConnectionFactoryLookupclass.- Parameters:
connectionFactories- theMapofConnectionFactory. The keys areStrings, the values are actualConnectionFactoryinstances.
-
MapConnectionFactoryLookup
public MapConnectionFactoryLookup(String connectionFactoryName, ConnectionFactory connectionFactory) Create a new instance of theMapConnectionFactoryLookupclass.- Parameters:
connectionFactoryName- the name under which the suppliedConnectionFactoryis to be addedconnectionFactory- theConnectionFactoryto be added
-
-
Method Details
-
setConnectionFactories
Set theMapofConnectionFactories. The keys areStrings, the values are actualConnectionFactoryinstances.If the supplied
Mapisnull, then this method call effectively has no effect.- Parameters:
connectionFactories- saidMapofconnectionFactories
-
getConnectionFactories
- Returns:
MapofconnectionFactory(nevernull)
-
addConnectionFactory
Add the suppliedConnectionFactoryto the map ofConnectionFactoryinstances maintained by this object.- Parameters:
connectionFactoryName- the name under which the suppliedConnectionFactoryis to be addedconnectionFactory- theConnectionFactoryto be so added
-
getConnectionFactory
public ConnectionFactory getConnectionFactory(String connectionFactoryName) throws ConnectionFactoryLookupFailureException Description copied from interface:ConnectionFactoryLookupRetrieve theConnectionFactoryidentified by the given name.- Specified by:
getConnectionFactoryin interfaceConnectionFactoryLookup- Parameters:
connectionFactoryName- the name of theConnectionFactory- Returns:
- the
ConnectionFactory(nevernull) - Throws:
ConnectionFactoryLookupFailureException- if the lookup failed
-