Top Description Fields Constructors Methods
org.springframework.r2dbc.connection.lookup

public Class MapConnectionFactoryLookup

extends Object
implements ConnectionFactoryLookup
Class Inheritance
All Implemented Interfaces
org.springframework.r2dbc.connection.lookup.ConnectionFactoryLookup
Imports
java.util.Collections, .HashMap, .Map, io.r2dbc.spi.ConnectionFactory, org.springframework.util.Assert

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.

Authors
Mark Paluch, Jens Schauder
Since
5.3

Field Summary

Modifier and TypeField and Description
private final Map<String, ConnectionFactory>

Constructor Summary

AccessConstructor and Description
public
MapConnectionFactoryLookup()

Create a new instance of the MapConnectionFactoryLookup class.

public
MapConnectionFactoryLookup(Map<String, ConnectionFactory>
the Map of ConnectionFactory. The keys are Strings, the values are actual ConnectionFactory instances.
connectionFactories
)

Create a new instance of the MapConnectionFactoryLookup class.

public
MapConnectionFactoryLookup(String
the name under which the supplied ConnectionFactory is to be added
connectionFactoryName
,
ConnectionFactory
the ConnectionFactory to be added
connectionFactory
)

Create a new instance of the MapConnectionFactoryLookup class.

Method Summary

Modifier and TypeMethod and Description
public void
addConnectionFactory(String
the name under which the supplied ConnectionFactory is to be added
connectionFactoryName
,
ConnectionFactory
the ConnectionFactory to be so added
connectionFactory
)

Add the supplied ConnectionFactory to the map of ConnectionFactory instances maintained by this object.

public Map<String, ConnectionFactory>

Returns:

Map of connectionFactory (never null)
getConnectionFactories
()

Get the Map of ConnectionFactories maintained by this object.

public ConnectionFactory
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionFactoriesback to summary
private final Map<String, ConnectionFactory> connectionFactories

Constructor Detail

MapConnectionFactoryLookupback to summary
public MapConnectionFactoryLookup()

Create a new instance of the MapConnectionFactoryLookup class.

MapConnectionFactoryLookupback to summary
public MapConnectionFactoryLookup(Map<String, ConnectionFactory> connectionFactories)

Create a new instance of the MapConnectionFactoryLookup class.

Parameters
connectionFactories:Map<String, ConnectionFactory>

the Map of ConnectionFactory. The keys are Strings, the values are actual ConnectionFactory instances.

MapConnectionFactoryLookupback to summary
public MapConnectionFactoryLookup(String connectionFactoryName, ConnectionFactory connectionFactory)

Create a new instance of the MapConnectionFactoryLookup class.

Parameters
connectionFactoryName:String

the name under which the supplied ConnectionFactory is to be added

connectionFactory:ConnectionFactory

the ConnectionFactory to be added

Method Detail

addConnectionFactoryback to summary
public void addConnectionFactory(String connectionFactoryName, ConnectionFactory connectionFactory)

Add the supplied ConnectionFactory to the map of ConnectionFactory instances maintained by this object.

Parameters
connectionFactoryName:String

the name under which the supplied ConnectionFactory is to be added

connectionFactory:ConnectionFactory

the ConnectionFactory to be so added

getConnectionFactoriesback to summary
public Map<String, ConnectionFactory> getConnectionFactories()

Get the Map of ConnectionFactories maintained by this object.

The returned Map is unmodifiable.

Returns:Map<String, ConnectionFactory>

Map of connectionFactory (never null)

getConnectionFactoryback to summary
public ConnectionFactory getConnectionFactory(String connectionFactoryName) throws ConnectionFactoryLookupFailureException

Implements org.springframework.r2dbc.connection.lookup.ConnectionFactoryLookup.getConnectionFactory.

Doc from org.springframework.r2dbc.connection.lookup.ConnectionFactoryLookup.getConnectionFactory.

Retrieve the ConnectionFactory identified by the given name.

Parameters
connectionFactoryName:String

the name of the ConnectionFactory

Returns:ConnectionFactory

the ConnectionFactory (never null)

Annotations
@Override
Exceptions
ConnectionFactoryLookupFailureException:
if the lookup failed
setConnectionFactoriesback to summary
public void setConnectionFactories(Map<String, ConnectionFactory> connectionFactories)

Set the Map of ConnectionFactories. The keys are Strings, the values are actual ConnectionFactory instances.

If the supplied Map is null, then this method call effectively has no effect.

Parameters
connectionFactories:Map<String, ConnectionFactory>

said Map of connectionFactories