Commit 4a6d8a30 by Spencer Gibb

removed circular dependency between EurekaClientAutoConfiguration and…

removed circular dependency between EurekaClientAutoConfiguration and EurekaDiscoveryClientConfiguration that caused DiscoveryClientConfigServiceBootstrapConfiguration to fail. fixes gh-99
parent f4681606
......@@ -17,9 +17,6 @@ package org.springframework.cloud.netflix.eureka;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.reader.MetricReader;
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.ConditionalOnMissingBean;
......@@ -28,7 +25,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.discovery.DiscoveryClient;
import com.netflix.discovery.EurekaClientConfig;
import com.netflix.discovery.converters.JsonXStream;
import com.netflix.discovery.converters.XmlXStream;
......@@ -40,13 +36,9 @@ import com.netflix.discovery.converters.XmlXStream;
@Configuration
@EnableConfigurationProperties
@ConditionalOnClass(EurekaClientConfig.class)
@ConditionalOnBean(DiscoveryClient.class)
@ConditionalOnExpression("${eureka.client.enabled:true}")
public class EurekaClientAutoConfiguration {
@Autowired
private DiscoveryClient discoveryClient;
@PostConstruct
public void init() {
XmlXStream.getInstance().setMarshallingStrategy(
......@@ -67,11 +59,5 @@ public class EurekaClientAutoConfiguration {
return new EurekaInstanceConfigBean();
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(MetricReader.class)
public EurekaHealthIndicator eurekaHealthIndicator(EurekaInstanceConfig config, MetricReader metrics) {
return new EurekaHealthIndicator(discoveryClient, metrics, config);
}
}
......@@ -17,10 +17,13 @@ package org.springframework.cloud.netflix.eureka;
import javax.annotation.PreDestroy;
import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.appinfo.HealthCheckHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.reader.MetricReader;
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.ConditionalOnMissingBean;
......@@ -169,4 +172,11 @@ public class EurekaDiscoveryClientConfiguration implements SmartLifecycle, Order
};
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(MetricReader.class)
public EurekaHealthIndicator eurekaHealthIndicator(EurekaInstanceConfig config, MetricReader metrics) {
return new EurekaHealthIndicator(eurekaDiscoveryClient(), metrics, config);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment