Browse Source

Class name change in Spring Boot

pull/56/head
Dave Syer 9 years ago
parent
commit
5d40088b7e
  1. 16
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessor.java

16
spring-cloud-commons/src/main/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessor.java

@ -3,7 +3,7 @@ package org.springframework.cloud.client;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigFileEnvironmentPostProcessor; import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.cloud.util.InetUtils; import org.springframework.cloud.util.InetUtils;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -13,24 +13,26 @@ import org.springframework.core.env.MapPropertySource;
/** /**
* @author Spencer Gibb * @author Spencer Gibb
*/ */
public class HostInfoEnvironmentPostProcessor implements public class HostInfoEnvironmentPostProcessor
EnvironmentPostProcessor, Ordered { implements EnvironmentPostProcessor, Ordered {
// Before ConfigFileApplicationListener // Before ConfigFileApplicationListener
private int order = ConfigFileEnvironmentPostProcessor.DEFAULT_ORDER - 1; private int order = ConfigFileApplicationListener.DEFAULT_ORDER - 1;
@Override @Override
public int getOrder() { public int getOrder() {
return order; return this.order;
} }
@Override @Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
InetUtils.HostInfo hostInfo = InetUtils.getFirstNonLoopbackHostInfo(); InetUtils.HostInfo hostInfo = InetUtils.getFirstNonLoopbackHostInfo();
LinkedHashMap<String, Object> map = new LinkedHashMap<>(); LinkedHashMap<String, Object> map = new LinkedHashMap<>();
map.put("spring.cloud.client.hostname", hostInfo.getHostname()); map.put("spring.cloud.client.hostname", hostInfo.getHostname());
map.put("spring.cloud.client.ipAddress", hostInfo.getIpAddress()); map.put("spring.cloud.client.ipAddress", hostInfo.getIpAddress());
MapPropertySource propertySource = new MapPropertySource("springCloudClientHostInfo", map); MapPropertySource propertySource = new MapPropertySource(
"springCloudClientHostInfo", map);
environment.getPropertySources().addLast(propertySource); environment.getPropertySources().addLast(propertySource);
} }
} }

Loading…
Cancel
Save