Class AbstractR2dbcConfiguration
java.lang.Object
org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration
- All Implemented Interfaces:
Aware
,ApplicationContextAware
@Configuration(proxyBeanMethods=false)
public abstract class AbstractR2dbcConfiguration
extends Object
implements ApplicationContextAware
Base class for Spring Data R2DBC configuration containing bean declarations that must be registered for Spring Data
R2DBC to work.
- Author:
- Mark Paluch
- See Also:
-
ConnectionFactory
DatabaseClient
EnableR2dbcRepositories
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract io.r2dbc.spi.ConnectionFactory
Return a R2DBCConnectionFactory
.Customization hook to return custom converters.getDialect
(io.r2dbc.spi.ConnectionFactory connectionFactory) Return aR2dbcDialect
for the givenConnectionFactory
.protected CustomConversions.StoreConversions
Returns theR2dbcDialect
-specificCustomConversions.StoreConversions
.r2dbcConverter
(R2dbcMappingContext mappingContext, R2dbcCustomConversions r2dbcCustomConversions) Creates aR2dbcConverter
using the configuredr2dbcMappingContext(Optional, R2dbcCustomConversions)
R2dbcMappingContext}.Register customConverter
s in aCustomConversions
object if required.r2dbcEntityTemplate
(DatabaseClient databaseClient, ReactiveDataAccessStrategy dataAccessStrategy) r2dbcMappingContext
(Optional<NamingStrategy> namingStrategy, R2dbcCustomConversions r2dbcCustomConversions) Register aR2dbcMappingContext
and apply an optionalNamingStrategy
.reactiveDataAccessStrategy
(R2dbcConverter converter) Creates aReactiveDataAccessStrategy
using the configuredR2dbcConverter
.void
setApplicationContext
(ApplicationContext applicationContext)
-
Constructor Details
-
AbstractR2dbcConfiguration
public AbstractR2dbcConfiguration()
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
connectionFactory
public abstract io.r2dbc.spi.ConnectionFactory connectionFactory()Return a R2DBCConnectionFactory
. Annotate withBean
in case you want to expose aConnectionFactory
instance to theApplicationContext
.- Returns:
- the configured
ConnectionFactory
.
-
getDialect
Return aR2dbcDialect
for the givenConnectionFactory
. This method attempts to resolve aR2dbcDialect
fromConnectionFactoryMetadata
. Override this method to specify a dialect instead of attempting to resolve one.- Parameters:
connectionFactory
- the configuredConnectionFactory
.- Returns:
- the resolved
R2dbcDialect
. - Throws:
DialectResolver.NoDialectException
- if theR2dbcDialect
cannot be determined.
-
databaseClient
- Returns:
- must not be null.
- Throws:
IllegalArgumentException
- if any of the required args is null.
-
r2dbcEntityTemplate
@Bean public R2dbcEntityTemplate r2dbcEntityTemplate(DatabaseClient databaseClient, ReactiveDataAccessStrategy dataAccessStrategy) - Parameters:
databaseClient
- must not be null.dataAccessStrategy
- must not be null.- Returns:
- Since:
- 1.2
-
r2dbcMappingContext
@Bean public R2dbcMappingContext r2dbcMappingContext(Optional<NamingStrategy> namingStrategy, R2dbcCustomConversions r2dbcCustomConversions) Register aR2dbcMappingContext
and apply an optionalNamingStrategy
.- Parameters:
namingStrategy
- optionalNamingStrategy
. UseNamingStrategy.INSTANCE
as fallback.r2dbcCustomConversions
- customized R2DBC conversions.- Returns:
- must not be null.
- Throws:
IllegalArgumentException
- if any of the required args is null.
-
reactiveDataAccessStrategy
Creates aReactiveDataAccessStrategy
using the configuredR2dbcConverter
.- Parameters:
converter
- the configuredR2dbcConverter
.- Returns:
- must not be null.
- Throws:
IllegalArgumentException
- if any of the mappingContext is null.- See Also:
-
r2dbcConverter
@Bean public MappingR2dbcConverter r2dbcConverter(R2dbcMappingContext mappingContext, R2dbcCustomConversions r2dbcCustomConversions) Creates aR2dbcConverter
using the configuredr2dbcMappingContext(Optional, R2dbcCustomConversions)
R2dbcMappingContext}.- Parameters:
mappingContext
- the configuredR2dbcMappingContext
.r2dbcCustomConversions
- customized R2DBC conversions.- Returns:
- must not be null.
- Throws:
IllegalArgumentException
- if any of the mappingContext is null.- Since:
- 1.2
- See Also:
-
r2dbcCustomConversions
Register customConverter
s in aCustomConversions
object if required. TheseCustomConversions
will be registered with theBasicRelationalConverter
andr2dbcMappingContext(Optional, R2dbcCustomConversions)
. Returns an emptyR2dbcCustomConversions
instance by default. OverridegetCustomConverters()
to supply custom converters.- Returns:
- must not be null.
- See Also:
-
getCustomConverters
Customization hook to return custom converters.- Returns:
- return custom converters.
-
getStoreConversions
Returns theR2dbcDialect
-specificCustomConversions.StoreConversions
.- Returns:
- the
R2dbcDialect
-specificCustomConversions.StoreConversions
.
-