Class BeanFactoryConnectionFactoryLookup
java.lang.Object
org.springframework.r2dbc.connection.lookup.BeanFactoryConnectionFactoryLookup
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,ConnectionFactoryLookup
public class BeanFactoryConnectionFactoryLookup
extends Object
implements ConnectionFactoryLookup, BeanFactoryAware
ConnectionFactoryLookup
implementation based on a
Spring BeanFactory
.
Will lookup Spring managed beans identified by bean name,
expecting them to be of type ConnectionFactory
.
- Since:
- 5.3
- Author:
- Mark Paluch
- See Also:
-
Constructor Summary
ConstructorDescriptionCreate a new instance of theBeanFactoryConnectionFactoryLookup
class.BeanFactoryConnectionFactoryLookup
(BeanFactory beanFactory) Create a new instance of theBeanFactoryConnectionFactoryLookup
class. -
Method Summary
Modifier and TypeMethodDescriptiongetConnectionFactory
(String connectionFactoryName) Retrieve theConnectionFactory
identified by the given name.void
setBeanFactory
(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.
-
Constructor Details
-
BeanFactoryConnectionFactoryLookup
public BeanFactoryConnectionFactoryLookup()Create a new instance of theBeanFactoryConnectionFactoryLookup
class.The BeanFactory to access must be set via
setBeanFactory
. -
BeanFactoryConnectionFactoryLookup
Create a new instance of theBeanFactoryConnectionFactoryLookup
class.Use of this constructor is redundant if this object is being created by a Spring IoC container, as the supplied
BeanFactory
will be replaced by theBeanFactory
that creates it (c.f. theBeanFactoryAware
contract). So only use this constructor if you are using this class outside the context of a Spring IoC container.- Parameters:
beanFactory
- the bean factory to be used to lookupConnectionFactories
-
-
Method Details
-
setBeanFactory
Description copied from interface:BeanFactoryAware
Callback that supplies the owning factory to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
-
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
-