diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java index 47b24254b..d9d8dd658 100644 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java +++ b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java @@ -1,28 +1,33 @@ package org.springframework.cloud.netflix.eureka.server; +import java.net.URI; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + import com.netflix.appinfo.AmazonInfo; import com.netflix.appinfo.ApplicationInfoManager; import com.netflix.appinfo.DataCenterInfo; import com.netflix.appinfo.InstanceInfo; import com.netflix.config.ConfigurationManager; -import com.netflix.discovery.shared.*; +import com.netflix.discovery.shared.Application; +import com.netflix.discovery.shared.Pair; import com.netflix.eureka.PeerAwareInstanceRegistry; import com.netflix.eureka.cluster.PeerEurekaNode; import com.netflix.eureka.resources.StatusResource; import com.netflix.eureka.util.StatusInfo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.web.ServerProperties; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; - -import java.net.URI; -import java.util.*; - /** * @author Spencer Gibb */ @@ -33,9 +38,6 @@ public class EurekaController { @Value("${eureka.dashboard.path:/}") private String dashboardPath = ""; - @Autowired - ServerProperties serverProperties; - @RequestMapping(method = RequestMethod.GET) public String status(HttpServletRequest request, Map model) { populateBase(request, model); diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaDashboardProperties.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaDashboardProperties.java new file mode 100644 index 000000000..b08834371 --- /dev/null +++ b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaDashboardProperties.java @@ -0,0 +1,41 @@ +/* + * Copyright 2013-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.cloud.netflix.eureka.server; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import lombok.Data; + +/** + * Configuration properties for the Eureka dashboard (UI). + * @author Dave Syer + * + */ +@ConfigurationProperties("eureka.dashboard") +@Data +public class EurekaDashboardProperties { + + /** + * The path to the Eureka dashboard (relative to the servlet path). Defaults to "/". + */ + private String path = "/"; + + /** + * FLag to enable the Eureka dashboard. Default true. + */ + private boolean enabled = true; + +} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java index d4c4bb61a..3aad138f2 100644 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java +++ b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java @@ -5,6 +5,7 @@ import javax.servlet.Filter; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.embedded.FilterRegistrationBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.eureka.EurekaServerConfigBean; import org.springframework.context.annotation.Bean; @@ -24,6 +25,7 @@ import com.sun.jersey.spi.container.servlet.ServletContainer; @Configuration @Import(EurekaServerInitializerConfiguration.class) @EnableDiscoveryClient +@EnableConfigurationProperties(EurekaDashboardProperties.class) public class EurekaServerConfiguration extends WebMvcConfigurerAdapter { @Bean