Skip to content

Commit

Permalink
Add RestTemplateEnabledCondition
Browse files Browse the repository at this point in the history
  • Loading branch information
heowc committed Oct 12, 2024
1 parent 4c7ce21 commit 871451c
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RestTemplateBuilder> restTemplateBuilders) throws GeneralSecurityException, IOException {
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -174,9 +172,9 @@ public WebClientNotFoundConfiguration() {

}

static class JerseyClientPresentAndEnabledCondition extends AllNestedConditions {
static class RestTemplateEnabledCondition extends AllNestedConditions {

JerseyClientPresentAndEnabledCondition() {
RestTemplateEnabledCondition() {
super(ConfigurationPhase.REGISTER_BEAN);
}

Expand All @@ -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 {
Expand Down

0 comments on commit 871451c

Please sign in to comment.