Browse Source

Use @ConditionalOnProperty where possible

pull/15/head
Dave Syer 10 years ago
parent
commit
7d751b76ee
  1. 8
      src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java
  2. 4
      src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java

8
src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java

@ -1,10 +1,12 @@ @@ -1,10 +1,12 @@
package org.springframework.cloud.client;
import java.util.List;
import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.DiscoveryClientHealthIndicator;
import org.springframework.cloud.client.discovery.DiscoveryCompositeHealthIndicator;
@ -13,8 +15,6 @@ import org.springframework.context.annotation.Bean; @@ -13,8 +15,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import java.util.List;
/**
* @author Spencer Gibb
*/
@ -25,7 +25,7 @@ public class CommonsClientAutoConfiguration { @@ -25,7 +25,7 @@ public class CommonsClientAutoConfiguration {
@Configuration
@ConditionalOnBean(DiscoveryClient.class)
@ConditionalOnExpression("${spring.cloud.discovery.enabled:true}")
@ConditionalOnProperty(value = "spring.cloud.discovery.enabled", matchIfMissing = true)
protected static class HealthConfiguration {
@Bean
public DiscoveryClientHealthIndicator instancesHealthIndicator(DiscoveryClient discoveryClient) {

4
src/main/java/org/springframework/cloud/client/discovery/NoopDiscoveryClientConfiguration.java

@ -23,8 +23,8 @@ import javax.annotation.PostConstruct; @@ -23,8 +23,8 @@ import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
@ -44,7 +44,7 @@ import org.springframework.core.env.Environment; @@ -44,7 +44,7 @@ import org.springframework.core.env.Environment;
@Configuration
@EnableConfigurationProperties
@ConditionalOnMissingClass(name = "com.netflix.discovery.EurekaClientConfig")
@ConditionalOnExpression("!${eureka.client.enabled:false}")
@ConditionalOnProperty(value = "eureka.client.enabled", havingValue = "false")
public class NoopDiscoveryClientConfiguration implements ApplicationListener<ContextRefreshedEvent> {
private static final Logger logger = LoggerFactory

Loading…
Cancel
Save