From aaecdfb527f460ccef2de99595d314e73818fcdf Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 2 Oct 2018 17:43:59 +0200 Subject: [PATCH] Deprecate Cassandra properties that require a default constructor Closes gh-14473 --- .../cassandra/CassandraAutoConfiguration.java | 1 + .../autoconfigure/cassandra/CassandraProperties.java | 10 ++++++++++ .../main/asciidoc/appendix-application-properties.adoc | 3 --- .../src/main/asciidoc/spring-boot-features.adoc | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index 551b9cddfd..f725167545 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java @@ -60,6 +60,7 @@ public class CassandraAutoConfiguration { @Bean @ConditionalOnMissingBean + @SuppressWarnings("deprecation") public Cluster cassandraCluster() { PropertyMapper map = PropertyMapper.get(); CassandraProperties properties = this.properties; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index 8613dcac96..db3a1dd813 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -31,6 +31,7 @@ import com.datastax.driver.core.policies.ReconnectionPolicy; import com.datastax.driver.core.policies.RetryPolicy; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.convert.DurationUnit; /** @@ -188,10 +189,13 @@ public class CassandraProperties { this.compression = compression; } + @DeprecatedConfigurationProperty(reason = "Implement a ClusterBuilderCustomizer bean instead.") + @Deprecated public Class getLoadBalancingPolicy() { return this.loadBalancingPolicy; } + @Deprecated public void setLoadBalancingPolicy( Class loadBalancingPolicy) { this.loadBalancingPolicy = loadBalancingPolicy; @@ -221,19 +225,25 @@ public class CassandraProperties { this.fetchSize = fetchSize; } + @DeprecatedConfigurationProperty(reason = "Implement a ClusterBuilderCustomizer bean instead.") + @Deprecated public Class getReconnectionPolicy() { return this.reconnectionPolicy; } + @Deprecated public void setReconnectionPolicy( Class reconnectionPolicy) { this.reconnectionPolicy = reconnectionPolicy; } + @DeprecatedConfigurationProperty(reason = "Implement a ClusterBuilderCustomizer bean instead.") + @Deprecated public Class getRetryPolicy() { return this.retryPolicy; } + @Deprecated public void setRetryPolicy(Class retryPolicy) { this.retryPolicy = retryPolicy; } diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 2b1372195e..6b7bec308d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -635,7 +635,6 @@ content into your application. Rather, pick only the properties that you need. spring.data.cassandra.contact-points=localhost # Cluster node addresses. spring.data.cassandra.fetch-size= # Queries default fetch size. spring.data.cassandra.keyspace-name= # Keyspace name to use. - spring.data.cassandra.load-balancing-policy= # Class name of the load balancing policy. The class must have a default constructor. spring.data.cassandra.port= # Port of the Cassandra server. spring.data.cassandra.password= # Login password of the server. spring.data.cassandra.pool.heartbeat-interval=30s # Heartbeat interval after which a message is sent on an idle connection to make sure it's still alive. If a duration suffix is not specified, seconds will be used. @@ -643,9 +642,7 @@ content into your application. Rather, pick only the properties that you need. spring.data.cassandra.pool.max-queue-size=256 # Maximum number of requests that get queued if no connection is available. spring.data.cassandra.pool.pool-timeout=5000ms # Pool timeout when trying to acquire a connection from a host's pool. spring.data.cassandra.read-timeout= # Socket option: read time out. - spring.data.cassandra.reconnection-policy= # Class name of the reconnection policy. The class must have a default constructor. spring.data.cassandra.repositories.type=auto # Type of Cassandra repositories to enable. - spring.data.cassandra.retry-policy= # Class name of the retry policy. The class must have a default constructor. spring.data.cassandra.serial-consistency-level= # Queries serial consistency level. spring.data.cassandra.schema-action=none # Schema action to take at startup. spring.data.cassandra.ssl=false # Enable SSL support. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index b567da9fcf..45a468de1d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -4578,6 +4578,9 @@ used to customize the connection. Generally, you provide `keyspace-name` and spring.data.cassandra.contact-points=cassandrahost1,cassandrahost2 ---- +You can also register an arbitrary number of beans that implement +`ClusterBuilderCustomizer` for more advanced customizations. + The following code listing shows how to inject a Cassandra bean: [source,java,indent=0]