From 871451c7fe1841ab3b11832dd564c0bab6f1a066 Mon Sep 17 00:00:00 2001 From: heowc Date: Sat, 12 Oct 2024 14:16:40 +0900 Subject: [PATCH] Add RestTemplateEnabledCondition --- ...coveryClientOptionalArgsConfiguration.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.java index d6e8fcd2e..1fa3b91ce 100644 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.java +++ b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.java @@ -73,10 +73,8 @@ public TlsProperties tlsProperties() { @Bean @ConditionalOnClass(name = "org.springframework.web.client.RestTemplate") - @Conditional(JerseyClientNotPresentOrNotEnabledCondition.class) + @Conditional(RestTemplateEnabledCondition.class) @ConditionalOnMissingBean(value = { AbstractDiscoveryClientOptionalArgs.class }, search = SearchStrategy.CURRENT) - @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", matchIfMissing = true, - havingValue = "false") public RestTemplateDiscoveryClientOptionalArgs restTemplateDiscoveryClientOptionalArgs(TlsProperties tlsProperties, EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier, ObjectProvider restTemplateBuilders) throws GeneralSecurityException, IOException { @@ -117,7 +115,7 @@ private static void setupTLS(AbstractDiscoveryClientOptionalArgs args, TlsPro } @Configuration(proxyBeanMethods = false) - @Conditional(JerseyClientPresentAndEnabledCondition.class) + @Conditional(RestTemplateEnabledCondition.class) @ConditionalOnBean(value = AbstractDiscoveryClientOptionalArgs.class, search = SearchStrategy.CURRENT) static class DiscoveryClientOptionalArgsTlsConfiguration { @@ -174,9 +172,9 @@ public WebClientNotFoundConfiguration() { } - static class JerseyClientPresentAndEnabledCondition extends AllNestedConditions { + static class RestTemplateEnabledCondition extends AllNestedConditions { - JerseyClientPresentAndEnabledCondition() { + RestTemplateEnabledCondition() { super(ConfigurationPhase.REGISTER_BEAN); } @@ -190,6 +188,18 @@ static class OnJerseyClientEnabled { } + @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", matchIfMissing = true, + havingValue = "false") + static class OnWebClientDisabled { + + } + + @ConditionalOnProperty(prefix = "eureka.client", name = "restclient.enabled", matchIfMissing = true, + havingValue = "false") + static class OnRestClientDisabled { + + } + } static class JerseyClientNotPresentOrNotEnabledCondition extends AnyNestedCondition {