Harmonize naming of Elasticsearch auto-configuration classes

pull/20923/head
Vedran Pavic 5 years ago committed by Brian Clozel
parent 2e37089d54
commit fec386b574

@ -29,7 +29,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration; import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -44,7 +44,7 @@ import org.springframework.context.annotation.Configuration;
@ConditionalOnClass(RestClient.class) @ConditionalOnClass(RestClient.class)
@ConditionalOnBean(RestClient.class) @ConditionalOnBean(RestClient.class)
@ConditionalOnEnabledHealthIndicator("elasticsearch") @ConditionalOnEnabledHealthIndicator("elasticsearch")
@AutoConfigureAfter(RestClientAutoConfiguration.class) @AutoConfigureAfter(ElasticsearchRestClientAutoConfiguration.class)
public class ElasticSearchRestHealthContributorAutoConfiguration public class ElasticSearchRestHealthContributorAutoConfiguration
extends CompositeHealthContributorConfiguration<ElasticsearchRestHealthIndicator, RestClient> { extends CompositeHealthContributorConfiguration<ElasticsearchRestHealthIndicator, RestClient> {

@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.data.elasticsearch;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration; import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
@ -39,7 +39,8 @@ import org.springframework.data.elasticsearch.repository.config.EnableReactiveEl
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ ElasticsearchTemplate.class }) @ConditionalOnClass({ ElasticsearchTemplate.class })
@AutoConfigureAfter({ RestClientAutoConfiguration.class, ReactiveRestClientAutoConfiguration.class }) @AutoConfigureAfter({ ElasticsearchRestClientAutoConfiguration.class,
ReactiveElasticsearchRestClientAutoConfiguration.class })
@Import({ ElasticsearchDataConfiguration.BaseConfiguration.class, @Import({ ElasticsearchDataConfiguration.BaseConfiguration.class,
ElasticsearchDataConfiguration.RestClientConfiguration.class, ElasticsearchDataConfiguration.RestClientConfiguration.class,
ElasticsearchDataConfiguration.ReactiveRestClientConfiguration.class }) ElasticsearchDataConfiguration.ReactiveRestClientConfiguration.class })

@ -42,12 +42,12 @@ import org.springframework.web.reactive.function.client.WebClient;
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ ReactiveRestClients.class, WebClient.class, HttpClient.class }) @ConditionalOnClass({ ReactiveRestClients.class, WebClient.class, HttpClient.class })
@EnableConfigurationProperties(ReactiveRestClientProperties.class) @EnableConfigurationProperties(ReactiveElasticsearchRestClientProperties.class)
public class ReactiveRestClientAutoConfiguration { public class ReactiveElasticsearchRestClientAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ClientConfiguration clientConfiguration(ReactiveRestClientProperties properties) { public ClientConfiguration clientConfiguration(ReactiveElasticsearchRestClientProperties properties) {
ClientConfiguration.MaybeSecureClientConfigurationBuilder builder = ClientConfiguration.builder() ClientConfiguration.MaybeSecureClientConfigurationBuilder builder = ClientConfiguration.builder()
.connectedTo(properties.getEndpoints().toArray(new String[0])); .connectedTo(properties.getEndpoints().toArray(new String[0]));
if (properties.isUseSsl()) { if (properties.isUseSsl()) {
@ -59,7 +59,7 @@ public class ReactiveRestClientAutoConfiguration {
} }
private void configureTimeouts(ClientConfiguration.TerminalClientConfigurationBuilder builder, private void configureTimeouts(ClientConfiguration.TerminalClientConfigurationBuilder builder,
ReactiveRestClientProperties properties) { ReactiveElasticsearchRestClientProperties properties) {
PropertyMapper map = PropertyMapper.get(); PropertyMapper map = PropertyMapper.get();
map.from(properties.getConnectionTimeout()).whenNonNull().to(builder::withConnectTimeout); map.from(properties.getConnectionTimeout()).whenNonNull().to(builder::withConnectTimeout);
map.from(properties.getSocketTimeout()).whenNonNull().to(builder::withSocketTimeout); map.from(properties.getSocketTimeout()).whenNonNull().to(builder::withSocketTimeout);
@ -71,7 +71,7 @@ public class ReactiveRestClientAutoConfiguration {
} }
private void configureExchangeStrategies(ClientConfiguration.TerminalClientConfigurationBuilder builder, private void configureExchangeStrategies(ClientConfiguration.TerminalClientConfigurationBuilder builder,
ReactiveRestClientProperties properties) { ReactiveElasticsearchRestClientProperties properties) {
PropertyMapper map = PropertyMapper.get(); PropertyMapper map = PropertyMapper.get();
builder.withWebClientConfigurer((webClient) -> { builder.withWebClientConfigurer((webClient) -> {
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder()

@ -31,7 +31,7 @@ import org.springframework.util.unit.DataSize;
* @since 2.2.0 * @since 2.2.0
*/ */
@ConfigurationProperties(prefix = "spring.data.elasticsearch.client.reactive") @ConfigurationProperties(prefix = "spring.data.elasticsearch.client.reactive")
public class ReactiveRestClientProperties { public class ReactiveElasticsearchRestClientProperties {
/** /**
* Comma-separated list of the Elasticsearch endpoints to connect to. * Comma-separated list of the Elasticsearch endpoints to connect to.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.elasticsearch.rest; package org.springframework.boot.autoconfigure.elasticsearch;
import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClient;
@ -33,10 +33,10 @@ import org.springframework.context.annotation.Import;
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RestClient.class) @ConditionalOnClass(RestClient.class)
@EnableConfigurationProperties(RestClientProperties.class) @EnableConfigurationProperties(ElasticsearchRestClientProperties.class)
@Import({ RestClientConfigurations.RestClientBuilderConfiguration.class, @Import({ ElasticsearchRestClientConfigurations.RestClientBuilderConfiguration.class,
RestClientConfigurations.RestHighLevelClientConfiguration.class, ElasticsearchRestClientConfigurations.RestHighLevelClientConfiguration.class,
RestClientConfigurations.RestClientFallbackConfiguration.class }) ElasticsearchRestClientConfigurations.RestClientFallbackConfiguration.class })
public class RestClientAutoConfiguration { public class ElasticsearchRestClientAutoConfiguration {
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.elasticsearch.rest; package org.springframework.boot.autoconfigure.elasticsearch;
import java.time.Duration; import java.time.Duration;
@ -41,14 +41,14 @@ import org.springframework.context.annotation.Configuration;
* @author Brian Clozel * @author Brian Clozel
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
class RestClientConfigurations { class ElasticsearchRestClientConfigurations {
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class RestClientBuilderConfiguration { static class RestClientBuilderConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
RestClientBuilder elasticsearchRestClientBuilder(RestClientProperties properties, RestClientBuilder elasticsearchRestClientBuilder(ElasticsearchRestClientProperties properties,
ObjectProvider<RestClientBuilderCustomizer> builderCustomizers) { ObjectProvider<RestClientBuilderCustomizer> builderCustomizers) {
HttpHost[] hosts = properties.getUris().stream().map(HttpHost::create).toArray(HttpHost[]::new); HttpHost[] hosts = properties.getUris().stream().map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(hosts); RestClientBuilder builder = RestClient.builder(hosts);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.elasticsearch.rest; package org.springframework.boot.autoconfigure.elasticsearch;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,7 +30,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @since 2.1.0 * @since 2.1.0
*/ */
@ConfigurationProperties(prefix = "spring.elasticsearch.rest") @ConfigurationProperties(prefix = "spring.elasticsearch.rest")
public class RestClientProperties { public class ElasticsearchRestClientProperties {
/** /**
* Comma-separated list of the Elasticsearch instances to use. * Comma-separated list of the Elasticsearch instances to use.

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.elasticsearch.rest; package org.springframework.boot.autoconfigure.elasticsearch;
import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestClientBuilder;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,6 +15,6 @@
*/ */
/** /**
* Auto-configuration for Elasticsearch REST clients. * Auto-configuration for Elasticsearch client.
*/ */
package org.springframework.boot.autoconfigure.elasticsearch.rest; package org.springframework.boot.autoconfigure.elasticsearch;

@ -41,7 +41,7 @@ org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoC
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\ org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\ org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration,\ org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveRestClientAutoConfiguration,\ org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRestClientAutoConfiguration,\
org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration,\ org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\ org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration,\ org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration,\
@ -60,7 +60,7 @@ org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,\ org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\ org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\ org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\
org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration,\ org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration,\
org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\
org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\ org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\
org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\ org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\

@ -21,7 +21,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration; import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -44,8 +44,8 @@ import static org.mockito.Mockito.mock;
class ElasticsearchDataAutoConfigurationTests { class ElasticsearchDataAutoConfigurationTests {
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class, .withConfiguration(AutoConfigurations.of(ElasticsearchRestClientAutoConfiguration.class,
ReactiveRestClientAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class)); ReactiveElasticsearchRestClientAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class));
@BeforeEach @BeforeEach
void setUp() { void setUp() {

@ -29,7 +29,7 @@ import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElastic
import org.springframework.boot.autoconfigure.data.elasticsearch.city.City; import org.springframework.boot.autoconfigure.data.elasticsearch.city.City;
import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository; import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository;
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage; import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration; import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
@ -52,7 +52,7 @@ class ElasticsearchRepositoriesAutoConfigurationTests {
.withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10)); .withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class, .withConfiguration(AutoConfigurations.of(ElasticsearchRestClientAutoConfiguration.class,
ElasticsearchRepositoriesAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class)) ElasticsearchRepositoriesAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class))
.withPropertyValues("spring.elasticsearch.rest.uris=" + elasticsearch.getHttpHostAddress()); .withPropertyValues("spring.elasticsearch.rest.uris=" + elasticsearch.getHttpHostAddress());

@ -51,7 +51,7 @@ public class ReactiveElasticsearchRepositoriesAutoConfigurationTests {
.withStartupTimeout(Duration.ofMinutes(10)); .withStartupTimeout(Duration.ofMinutes(10));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ReactiveRestClientAutoConfiguration.class, .withConfiguration(AutoConfigurations.of(ReactiveElasticsearchRestClientAutoConfiguration.class,
ReactiveElasticsearchRepositoriesAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class)) ReactiveElasticsearchRepositoriesAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class))
.withPropertyValues("spring.data.elasticsearch.client.reactive.endpoints=" .withPropertyValues("spring.data.elasticsearch.client.reactive.endpoints="
+ elasticsearch.getContainerIpAddress() + ":" + elasticsearch.getFirstMappedPort()); + elasticsearch.getContainerIpAddress() + ":" + elasticsearch.getFirstMappedPort());

@ -39,19 +39,19 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
* Tests for {@link ReactiveRestClientAutoConfiguration} * Tests for {@link ReactiveElasticsearchRestClientAutoConfiguration}.
* *
* @author Brian Clozel * @author Brian Clozel
*/ */
@Testcontainers(disabledWithoutDocker = true) @Testcontainers(disabledWithoutDocker = true)
public class ReactiveRestClientAutoConfigurationTests { public class ReactiveElasticsearchRestClientAutoConfigurationTests {
@Container @Container
static ElasticsearchContainer elasticsearch = new VersionOverridingElasticsearchContainer().withStartupAttempts(5) static ElasticsearchContainer elasticsearch = new VersionOverridingElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10)); .withStartupTimeout(Duration.ofMinutes(10));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ReactiveRestClientAutoConfiguration.class)); .withConfiguration(AutoConfigurations.of(ReactiveElasticsearchRestClientAutoConfiguration.class));
@Test @Test
void configureShouldCreateDefaultBeans() { void configureShouldCreateDefaultBeans() {

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.elasticsearch.rest; package org.springframework.boot.autoconfigure.elasticsearch;
import java.time.Duration; import java.time.Duration;
import java.util.HashMap; import java.util.HashMap;
@ -42,19 +42,19 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
* Tests for {@link RestClientAutoConfiguration} * Tests for {@link ElasticsearchRestClientAutoConfiguration}.
* *
* @author Brian Clozel * @author Brian Clozel
*/ */
@Testcontainers(disabledWithoutDocker = true) @Testcontainers(disabledWithoutDocker = true)
class RestClientAutoConfigurationTests { class ElasticsearchRestClientAutoConfigurationTests {
@Container @Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5) static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(10)); .withStartupTimeout(Duration.ofMinutes(10));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class)); .withConfiguration(AutoConfigurations.of(ElasticsearchRestClientAutoConfiguration.class));
@Test @Test
void configureShouldCreateBothRestClientVariants() { void configureShouldCreateBothRestClientVariants() {
Loading…
Cancel
Save