Don't use deprecated constructor.

Eliminates a legacy use of a static singleton. This will help allow multiple registrations.
parent 83cdf647
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
package org.springframework.cloud.netflix.ribbon.eureka; package org.springframework.cloud.netflix.ribbon.eureka;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.inject.Provider;
import com.netflix.discovery.EurekaClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
...@@ -89,9 +91,9 @@ public class EurekaRibbonClientConfiguration { ...@@ -89,9 +91,9 @@ public class EurekaRibbonClientConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ServerList<?> ribbonServerList(IClientConfig config) { public ServerList<?> ribbonServerList(IClientConfig config, Provider<EurekaClient> eurekaClientProvider) {
DiscoveryEnabledNIWSServerList discoveryServerList = new DiscoveryEnabledNIWSServerList( DiscoveryEnabledNIWSServerList discoveryServerList = new DiscoveryEnabledNIWSServerList(
config); config, eurekaClientProvider);
DomainExtractingServerList serverList = new DomainExtractingServerList( DomainExtractingServerList serverList = new DomainExtractingServerList(
discoveryServerList, config, this.approximateZoneFromHostname); discoveryServerList, config, this.approximateZoneFromHostname);
return serverList; return serverList;
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
package org.springframework.cloud.netflix.ribbon.eureka; package org.springframework.cloud.netflix.ribbon.eureka;
import com.netflix.discovery.EurekaClient;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
...@@ -92,6 +94,10 @@ public class RibbonClientPreprocessorIntegrationTests { ...@@ -92,6 +94,10 @@ public class RibbonClientPreprocessorIntegrationTests {
ArchaiusAutoConfiguration.class, RibbonAutoConfiguration.class, ArchaiusAutoConfiguration.class, RibbonAutoConfiguration.class,
RibbonEurekaAutoConfiguration.class }) RibbonEurekaAutoConfiguration.class })
protected static class TestConfiguration { protected static class TestConfiguration {
@Bean
EurekaClient eurekaClient() {
return Mockito.mock(EurekaClient.class);
}
} }
@Configuration @Configuration
......
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