Update build and fix race in eureka

This commit is contained in:
Dave Syer
2014-08-14 21:44:50 -07:00
parent c8be52b025
commit 1f63ea919c
2 changed files with 13 additions and 2 deletions

View File

@@ -27,6 +27,9 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.SmartLifecycle;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered;
@@ -109,6 +112,8 @@ public class EurekaClientConfiguration implements
}
@Bean
@Lazy
@Scope(proxyMode=ScopedProxyMode.TARGET_CLASS)
public DiscoveryClient discoveryClient() {
return DiscoveryManager.getInstance().getDiscoveryClient();
}

View File

@@ -66,7 +66,7 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
private int leaseExpirationDurationInSeconds = 90;
@Value("${spring.application.name:unknown}") //TODO: why is .mydomain.net here?
@Value("${spring.application.name:unknown}")
private String virtualHostName;
private String secureVirtualHostName;
@@ -99,6 +99,12 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
private String namespace = "eureka";
private String hostname = hostInfo[1];
private boolean preferIpAddress = false;
public String getHostname() {
return preferIpAddress ? ipAddress : hostname;
}
@Override
public boolean getSecurePortEnabled() {
@@ -118,7 +124,7 @@ public class EurekaInstanceConfigBean implements EurekaInstanceConfig {
@Override
public String getHostName(boolean refresh) {
return hostname;
return preferIpAddress ? ipAddress : hostname;
}
}