Browse Source

Update namespace method

pull/323/head
Spencer Gibb 7 years ago
parent
commit
af5438bc91
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 16
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistration.java

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

@ -1,16 +1,10 @@
package org.springframework.cloud.client.serviceregistry; package org.springframework.cloud.client.serviceregistry;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PreDestroy;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.boot.web.context.ConfigurableWebServerApplicationContext;
import org.springframework.boot.web.context.WebServerInitializedEvent; import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.cloud.client.discovery.ManagementServerPortUtils; import org.springframework.cloud.client.discovery.ManagementServerPortUtils;
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -18,6 +12,10 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import javax.annotation.PreDestroy;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* Lifecycle methods that may be useful and common to {@link ServiceRegistry} * Lifecycle methods that may be useful and common to {@link ServiceRegistry}
* implementations. * implementations.
@ -65,9 +63,9 @@ public abstract class AbstractAutoServiceRegistration<R extends Registration>
@EventListener(WebServerInitializedEvent.class) @EventListener(WebServerInitializedEvent.class)
public void bind(WebServerInitializedEvent event) { public void bind(WebServerInitializedEvent event) {
ApplicationContext context = event.getApplicationContext(); ApplicationContext context = event.getApplicationContext();
if (context instanceof ServletWebServerApplicationContext) { if (context instanceof ConfigurableWebServerApplicationContext) {
if ("management".equals( if ("management".equals(
((ServletWebServerApplicationContext) context).getNamespace())) { ((ConfigurableWebServerApplicationContext) context).getServerNamespace())) {
return; return;
} }
} }

Loading…
Cancel
Save