Commit eba7f0da by Spencer Gibb

move SpringClientFactory bean creation to RibbonAutoConfiguration where it…

move SpringClientFactory bean creation to RibbonAutoConfiguration where it should have been in the first place. fixes gh-35
parent 9768a76b
...@@ -142,11 +142,6 @@ public class EurekaClientConfiguration implements SmartLifecycle, Ordered { ...@@ -142,11 +142,6 @@ public class EurekaClientConfiguration implements SmartLifecycle, Ordered {
} }
@Bean @Bean
public SpringClientFactory springClientFactory() {
return new SpringClientFactory();
}
@Bean
protected ApplicationListener<EmbeddedServletContainerInitializedEvent> containerPortInitializer() { protected ApplicationListener<EmbeddedServletContainerInitializedEvent> containerPortInitializer() {
return new ApplicationListener<EmbeddedServletContainerInitializedEvent>() { return new ApplicationListener<EmbeddedServletContainerInitializedEvent>() {
......
...@@ -6,7 +6,7 @@ import java.util.List; ...@@ -6,7 +6,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration; import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
...@@ -15,6 +15,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -15,6 +15,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.netflix.client.IClient;
import com.netflix.loadbalancer.BaseLoadBalancer; import com.netflix.loadbalancer.BaseLoadBalancer;
/** /**
...@@ -23,18 +24,17 @@ import com.netflix.loadbalancer.BaseLoadBalancer; ...@@ -23,18 +24,17 @@ import com.netflix.loadbalancer.BaseLoadBalancer;
* @author Dave Syer * @author Dave Syer
*/ */
@Configuration @Configuration
@ConditionalOnBean(SpringClientFactory.class) @ConditionalOnClass(IClient.class)
@AutoConfigureAfter(EurekaClientAutoConfiguration.class) @AutoConfigureAfter(EurekaClientAutoConfiguration.class)
public class RibbonAutoConfiguration { public class RibbonAutoConfiguration {
@Autowired(required = false) @Autowired(required = false)
private List<BaseLoadBalancer> balancers = Collections.emptyList(); private List<BaseLoadBalancer> balancers = Collections.emptyList();
@Autowired @Bean
private RibbonClientPreprocessor clientPreprocessor; public SpringClientFactory springClientFactory() {
return new SpringClientFactory();
@Autowired }
private SpringClientFactory springClientFactory;
@Bean @Bean
@ConditionalOnMissingBean(RestTemplate.class) @ConditionalOnMissingBean(RestTemplate.class)
...@@ -48,8 +48,8 @@ public class RibbonAutoConfiguration { ...@@ -48,8 +48,8 @@ public class RibbonAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(LoadBalancerClient.class) @ConditionalOnMissingBean(LoadBalancerClient.class)
public LoadBalancerClient loadBalancerClient() { public LoadBalancerClient loadBalancerClient(RibbonClientPreprocessor clientPreprocessor) {
return new RibbonLoadBalancerClient(clientPreprocessor, springClientFactory, balancers); return new RibbonLoadBalancerClient(clientPreprocessor, springClientFactory(), balancers);
} }
@Bean @Bean
......
...@@ -17,6 +17,7 @@ package org.springframework.cloud.netflix.ribbon.eureka; ...@@ -17,6 +17,7 @@ package org.springframework.cloud.netflix.ribbon.eureka;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
...@@ -36,6 +37,7 @@ import com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList; ...@@ -36,6 +37,7 @@ import com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList;
@Configuration @Configuration
@EnableConfigurationProperties @EnableConfigurationProperties
@ConditionalOnClass(DiscoveryEnabledNIWSServerList.class) @ConditionalOnClass(DiscoveryEnabledNIWSServerList.class)
@ConditionalOnBean(SpringClientFactory.class)
@ConditionalOnExpression("${ribbon.eureka.enabled:true}") @ConditionalOnExpression("${ribbon.eureka.enabled:true}")
@AutoConfigureAfter(RibbonAutoConfiguration.class) @AutoConfigureAfter(RibbonAutoConfiguration.class)
public class RibbonEurekaAutoConfiguration { public class RibbonEurekaAutoConfiguration {
......
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