Browse Source

Moves conditional on class to class level

wip-poc-gh-595-power-of-two-loadbalancer
Spencer Gibb 5 years ago
parent
commit
6f83156c73
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 3
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java
  2. 2
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfiguration.java
  3. 24
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/reactive/SimpleReactiveDiscoveryClientAutoConfiguration.java
  4. 2
      spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java
  5. 2
      spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java

3
spring-cloud-commons/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java

@ -52,6 +52,7 @@ import org.springframework.context.annotation.Configuration; @@ -52,6 +52,7 @@ import org.springframework.context.annotation.Configuration;
public class CommonsClientAutoConfiguration {
@Configuration
@ConditionalOnClass(HealthIndicator.class)
@EnableConfigurationProperties(DiscoveryClientHealthIndicatorProperties.class)
@ConditionalOnBean(DiscoveryClient.class)
@ConditionalOnDiscoveryEnabled
@ -59,7 +60,6 @@ public class CommonsClientAutoConfiguration { @@ -59,7 +60,6 @@ public class CommonsClientAutoConfiguration {
protected static class DiscoveryLoadBalancerConfiguration {
@Bean
@ConditionalOnClass(HealthIndicator.class)
@ConditionalOnDiscoveryHealthIndicatorEnabled
public DiscoveryClientHealthIndicator discoveryClientHealthIndicator(
ObjectProvider<DiscoveryClient> discoveryClient,
@ -68,7 +68,6 @@ public class CommonsClientAutoConfiguration { @@ -68,7 +68,6 @@ public class CommonsClientAutoConfiguration {
}
@Bean
@ConditionalOnClass(HealthIndicator.class)
@ConditionalOnProperty(
value = "spring.cloud.discovery.client.composite-indicator.enabled",
matchIfMissing = true)

2
spring-cloud-commons/src/main/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfiguration.java

@ -45,13 +45,13 @@ public class ReactiveCommonsClientAutoConfiguration { @@ -45,13 +45,13 @@ public class ReactiveCommonsClientAutoConfiguration {
@Configuration
@EnableConfigurationProperties(DiscoveryClientHealthIndicatorProperties.class)
@ConditionalOnClass(ReactiveHealthIndicator.class)
@ConditionalOnBean(ReactiveDiscoveryClient.class)
@ConditionalOnDiscoveryEnabled
@ConditionalOnReactiveDiscoveryEnabled
protected static class ReactiveDiscoveryLoadBalancerConfiguration {
@Bean
@ConditionalOnClass(ReactiveHealthIndicator.class)
@ConditionalOnProperty(
value = "spring.cloud.discovery.client.composite-indicator.enabled",
matchIfMissing = true)

24
spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/reactive/SimpleReactiveDiscoveryClientAutoConfiguration.java

@ -82,15 +82,6 @@ public class SimpleReactiveDiscoveryClientAutoConfiguration @@ -82,15 +82,6 @@ public class SimpleReactiveDiscoveryClientAutoConfiguration
return new SimpleReactiveDiscoveryClient(simpleReactiveDiscoveryProperties());
}
@Bean
@ConditionalOnClass(ReactiveHealthIndicator.class)
@ConditionalOnDiscoveryHealthIndicatorEnabled
public ReactiveDiscoveryClientHealthIndicator simpleReactiveDiscoveryClientHealthIndicator(
DiscoveryClientHealthIndicatorProperties properties) {
return new ReactiveDiscoveryClientHealthIndicator(simpleReactiveDiscoveryClient(),
properties);
}
private int findPort() {
if (port > 0) {
return port;
@ -110,4 +101,19 @@ public class SimpleReactiveDiscoveryClientAutoConfiguration @@ -110,4 +101,19 @@ public class SimpleReactiveDiscoveryClientAutoConfiguration
}
}
@Configuration
@ConditionalOnClass(ReactiveHealthIndicator.class)
protected static class HealthConfiguration {
@Bean
@ConditionalOnDiscoveryHealthIndicatorEnabled
public ReactiveDiscoveryClientHealthIndicator simpleReactiveDiscoveryClientHealthIndicator(
DiscoveryClientHealthIndicatorProperties properties,
SimpleReactiveDiscoveryClient simpleReactiveDiscoveryClient) {
return new ReactiveDiscoveryClientHealthIndicator(
simpleReactiveDiscoveryClient, properties);
}
}
}

2
spring-cloud-commons/src/test/java/org/springframework/cloud/client/CommonsClientAutoConfigurationTests.java

@ -126,7 +126,7 @@ public class CommonsClientAutoConfigurationTests { @@ -126,7 +126,7 @@ public class CommonsClientAutoConfigurationTests {
.doesNotHaveBean(DiscoveryClientHealthIndicator.class);
assertThat(context)
.doesNotHaveBean(DiscoveryCompositeHealthIndicator.class);
then(context.getBeansOfType(HasFeatures.class).values()).isNotEmpty();
then(context.getBeansOfType(HasFeatures.class).values()).isEmpty();
});
}

2
spring-cloud-commons/src/test/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfigurationTests.java

@ -123,7 +123,7 @@ public class ReactiveCommonsClientAutoConfigurationTests { @@ -123,7 +123,7 @@ public class ReactiveCommonsClientAutoConfigurationTests {
ReactiveDiscoveryClientHealthIndicator.class);
assertThat(context).doesNotHaveBean(
ReactiveDiscoveryCompositeHealthContributor.class);
then(context.getBeansOfType(HasFeatures.class).values()).isNotEmpty();
then(context.getBeansOfType(HasFeatures.class).values()).isEmpty();
});
}

Loading…
Cancel
Save