From 27247e8d0d8782f10c03607b9660c74a37eadb43 Mon Sep 17 00:00:00 2001 From: agrgr Date: Sun, 29 Sep 2024 10:20:40 +0300 Subject: [PATCH] update configuration properties prefix, add bean names --- .../AbstractAerospikeDataConfiguration.java | 2 +- ...ractReactiveAerospikeDataConfiguration.java | 4 ++-- .../config/AerospikeConnectionSettings.java | 4 ++++ .../AerospikeDataConfigurationSupport.java | 9 +++------ .../config/AerospikeDataSettings.java | 4 ++++ src/main/resources/application.properties | 18 +++++++++--------- .../data/aerospike/BaseIntegrationTests.java | 2 +- .../aerospike/config/CommonTestConfig.java | 2 +- .../IndexNotScheduledCacheRefreshTest.java | 2 +- .../index/IndexScheduledCacheRefreshTest.java | 2 +- .../index/IndexedAnnotationTests.java | 2 +- src/test/resources/application.properties | 18 +++++++++--------- 12 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java b/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java index 1ea4c8f1b..cd1298437 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java +++ b/src/main/java/org/springframework/data/aerospike/config/AbstractAerospikeDataConfiguration.java @@ -72,7 +72,7 @@ public QueryEngine queryEngine(IAerospikeClient aerospikeClient, return queryEngine; } - @Bean + @Bean(name = "aerospikePersistenceEntityIndexCreator") public AerospikePersistenceEntityIndexCreator aerospikePersistenceEntityIndexCreator( ObjectProvider aerospikeMappingContext, AerospikeIndexResolver aerospikeIndexResolver, diff --git a/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java b/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java index cd379e9d6..9eb795d9f 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java +++ b/src/main/java/org/springframework/data/aerospike/config/AbstractReactiveAerospikeDataConfiguration.java @@ -105,8 +105,8 @@ protected ClientPolicy getClientPolicy() { return clientPolicy; } - @Bean - public ReactiveAerospikePersistenceEntityIndexCreator aerospikePersistenceEntityIndexCreator( + @Bean(name = "reactiveAerospikePersistenceEntityIndexCreator") + public ReactiveAerospikePersistenceEntityIndexCreator reactiveAerospikePersistenceEntityIndexCreator( ObjectProvider aerospikeMappingContext, AerospikeIndexResolver aerospikeIndexResolver, ObjectProvider template, AerospikeSettings settings) { diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeConnectionSettings.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeConnectionSettings.java index 13b4d675b..7da30618b 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AerospikeConnectionSettings.java +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeConnectionSettings.java @@ -18,9 +18,13 @@ import com.aerospike.client.Host; import lombok.Getter; import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import static org.springframework.data.aerospike.config.AerospikeDataConfigurationSupport.CONFIG_PREFIX_CONNECTION; @Setter @Getter +@ConfigurationProperties(prefix = CONFIG_PREFIX_CONNECTION) public class AerospikeConnectionSettings { // String of hosts separated by ',' in form of hostname1[:tlsName1]:port1,... diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java index a65d5cc45..b484c8a46 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataConfigurationSupport.java @@ -30,7 +30,6 @@ import io.netty.channel.nio.NioEventLoopGroup; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; import org.springframework.context.annotation.Configuration; @@ -71,9 +70,9 @@ @Configuration public abstract class AerospikeDataConfigurationSupport { - protected static final String CONFIG_PREFIX = "spring-data-aerospike"; - protected static final String CONFIG_PREFIX_DATA = CONFIG_PREFIX + ".data"; - protected static final String CONFIG_PREFIX_CONNECTION = CONFIG_PREFIX + ".connection"; + public static final String CONFIG_PREFIX = "spring.aerospike"; + public static final String CONFIG_PREFIX_DATA = CONFIG_PREFIX + ".data"; + public static final String CONFIG_PREFIX_CONNECTION = CONFIG_PREFIX + ".connection"; @Bean(name = "aerospikeStatementBuilder") public StatementBuilder statementBuilder(IndexesCache indexesCache) { @@ -267,13 +266,11 @@ protected ClientPolicy getClientPolicy() { } @Bean - @ConfigurationProperties(prefix = CONFIG_PREFIX_DATA) public AerospikeDataSettings readAerospikeDataSettings() { return new AerospikeDataSettings(); } @Bean - @ConfigurationProperties(prefix = CONFIG_PREFIX_CONNECTION) public AerospikeConnectionSettings readAerospikeSettings() { return new AerospikeConnectionSettings(); } diff --git a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java index 638c59dc3..a300629e8 100644 --- a/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java +++ b/src/main/java/org/springframework/data/aerospike/config/AerospikeDataSettings.java @@ -17,9 +17,13 @@ import lombok.Getter; import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import static org.springframework.data.aerospike.config.AerospikeDataConfigurationSupport.CONFIG_PREFIX_DATA; @Setter @Getter +@ConfigurationProperties(prefix = CONFIG_PREFIX_DATA) public class AerospikeDataSettings { // Enable scan operation diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 810ce0dcf..5fd8ecfac 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,9 +1,9 @@ -spring-data-aerospike.connection.hosts=localhost:3000 -spring-data-aerospike.connection.namespace=test -spring-data-aerospike.data.scans-enabled=false -spring-data-aerospike.data.create-indexes-on-startup=true -spring-data-aerospike.data.index-cache-refresh-seconds=3600 -spring-data-aerospike.data.server-version-refresh-seconds=3600 -spring-data-aerospike.data.query-max-records=10000 -spring-data-aerospike.data.batch-write-size=100 -spring-data-aerospike.data.keep-original-key-types=false \ No newline at end of file +spring.aerospike.connection.hosts=localhost:3000 +spring.aerospike.connection.namespace=test +spring.aerospike.data.scans-enabled=false +spring.aerospike.data.create-indexes-on-startup=true +spring.aerospike.data.index-cache-refresh-seconds=3600 +spring.aerospike.data.server-version-refresh-seconds=3600 +spring.aerospike.data.query-max-records=10000 +spring.aerospike.data.batch-write-size=100 +spring.aerospike.data.keep-original-key-types=false \ No newline at end of file diff --git a/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java index 7a5aa9293..b27c20ee5 100644 --- a/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/BaseIntegrationTests.java @@ -16,7 +16,7 @@ public abstract class BaseIntegrationTests { public static final String DIFFERENT_EXISTING_CACHE = "DIFFERENT-EXISTING-CACHE"; protected static final int MILLIS_TO_NANO = 1_000_000; - @Value("${spring-data-aerospike.connection.namespace}") + @Value("${spring.aerospike.connection.namespace}") protected String namespace; protected String id; diff --git a/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java b/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java index 80a636c9c..b77617916 100644 --- a/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java +++ b/src/test/java/org/springframework/data/aerospike/config/CommonTestConfig.java @@ -43,7 +43,7 @@ @EnableAutoConfiguration public class CommonTestConfig { - @Value("${spring-data-aerospike.connection.namespace}") + @Value("${spring.aerospike.connection.namespace}") protected String namespace; @Bean diff --git a/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java b/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java index 07e6f062f..7136cf24c 100644 --- a/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java +++ b/src/test/java/org/springframework/data/aerospike/index/IndexNotScheduledCacheRefreshTest.java @@ -15,7 +15,7 @@ @Slf4j @ContextConfiguration -@TestPropertySource(properties = {"spring-data-aerospike.data.server-version-refresh-seconds = 0"}) +@TestPropertySource(properties = {"spring.aerospike.data.server-version-refresh-seconds = 0"}) public class IndexNotScheduledCacheRefreshTest extends BaseBlockingIntegrationTests { String setName = "scheduled"; diff --git a/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java b/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java index 49c724c9f..f6e038a8f 100644 --- a/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java +++ b/src/test/java/org/springframework/data/aerospike/index/IndexScheduledCacheRefreshTest.java @@ -15,7 +15,7 @@ @Slf4j @ContextConfiguration -@TestPropertySource(properties = {"spring-data-aerospike.data.index-cache-refresh-seconds=4"}) +@TestPropertySource(properties = {"spring.aerospike.data.index-cache-refresh-seconds=4"}) public class IndexScheduledCacheRefreshTest extends BaseBlockingIntegrationTests { String setName = "scheduled"; diff --git a/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java b/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java index 01a5c7aca..13d7869c3 100644 --- a/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java +++ b/src/test/java/org/springframework/data/aerospike/index/IndexedAnnotationTests.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; -@TestPropertySource(properties = {"spring-data-aerospike.data.create-indexes-on-startup=true"}) +@TestPropertySource(properties = {"spring.aerospike.data.create-indexes-on-startup=true"}) // this test class requires secondary indexes created on startup public class IndexedAnnotationTests extends BaseBlockingIntegrationTests { diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 7030f0c82..588023579 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -1,9 +1,9 @@ -spring-data-aerospike.connection.hosts=${embedded.aerospike.host}:${embedded.aerospike.port} -spring-data-aerospike.connection.namespace=${embedded.aerospike.namespace} -spring-data-aerospike.data.scans-enabled=true -spring-data-aerospike.data.create-indexes-on-startup=false -spring-data-aerospike.data.index-cache-refresh-seconds=0 -spring-data-aerospike.data.server-version-refresh-seconds=0 -spring-data-aerospike.data.query-max-records=5000 -spring-data-aerospike.data.batch-write-size=100 -spring-data-aerospike.data.keep-original-key-types=false \ No newline at end of file +spring.aerospike.connection.hosts=${embedded.aerospike.host}:${embedded.aerospike.port} +spring.aerospike.connection.namespace=${embedded.aerospike.namespace} +spring.aerospike.data.scans-enabled=true +spring.aerospike.data.create-indexes-on-startup=false +spring.aerospike.data.index-cache-refresh-seconds=0 +spring.aerospike.data.server-version-refresh-seconds=0 +spring.aerospike.data.query-max-records=5000 +spring.aerospike.data.batch-write-size=100 +spring.aerospike.data.keep-original-key-types=false \ No newline at end of file