From af5438bc91904ff2d72ed7515a57dec41e7bbf4e Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Sat, 10 Feb 2018 09:51:42 -0500 Subject: [PATCH] Update namespace method --- .../AbstractAutoServiceRegistration.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistration.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistration.java index efad4f43..afa67d2d 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistration.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/serviceregistry/AbstractAutoServiceRegistration.java @@ -1,16 +1,10 @@ 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.LogFactory; - import org.springframework.beans.BeansException; +import org.springframework.boot.web.context.ConfigurableWebServerApplicationContext; 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.event.InstanceRegisteredEvent; import org.springframework.context.ApplicationContext; @@ -18,6 +12,10 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.event.EventListener; 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} * implementations. @@ -65,9 +63,9 @@ public abstract class AbstractAutoServiceRegistration @EventListener(WebServerInitializedEvent.class) public void bind(WebServerInitializedEvent event) { ApplicationContext context = event.getApplicationContext(); - if (context instanceof ServletWebServerApplicationContext) { + if (context instanceof ConfigurableWebServerApplicationContext) { if ("management".equals( - ((ServletWebServerApplicationContext) context).getNamespace())) { + ((ConfigurableWebServerApplicationContext) context).getServerNamespace())) { return; } }