diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle
index 548da5bd61..d41b142fa7 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle
@@ -172,6 +172,7 @@ dependencies {
testImplementation("org.mockito:mockito-core")
testImplementation("org.mockito:mockito-junit-jupiter")
testImplementation("org.skyscreamer:jsonassert")
+ testImplementation("org.springframework:spring-core-test")
testImplementation("org.springframework:spring-orm")
testImplementation("org.springframework.data:spring-data-rest-webmvc")
testImplementation("org.springframework.integration:spring-integration-jmx")
@@ -237,3 +238,7 @@ task zip(type: Zip) {
artifacts {
documentation zip
}
+
+test {
+ jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED"
+}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java
index d1a9bc8a7e..2363147fa3 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/ManagementContextFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2019 the original author or authors.
+ * Copyright 2012-2022 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.
@@ -16,26 +16,84 @@
package org.springframework.boot.actuate.autoconfigure.web;
-import org.springframework.boot.web.context.ConfigurableWebServerApplicationContext;
+import java.lang.reflect.Modifier;
+
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.boot.ApplicationContextFactory;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigRegistry;
/**
* Factory for creating a separate management context when the management web server is
* running on a different port to the main application.
+ *
+ * For internal use only.
*
* @author Andy Wilkinson
- * @since 2.0.0
+ * @author Phillip Webb
+ * @since 3.0.0
*/
-@FunctionalInterface
-public interface ManagementContextFactory {
+public final class ManagementContextFactory {
- /**
- * Create the management application context.
- * @param parent the parent context
- * @param configurationClasses the configuration classes
- * @return a configured application context
- */
- ConfigurableWebServerApplicationContext createManagementContext(ApplicationContext parent,
- Class>... configurationClasses);
+ private final WebApplicationType webApplicationType;
+
+ private final Class extends WebServerFactory> webServerFactoryClass;
+
+ private Class>[] autoConfigurationClasses;
+
+ public ManagementContextFactory(WebApplicationType webApplicationType,
+ Class extends WebServerFactory> webServerFactoryClass, Class>... autoConfigurationClasses) {
+ this.webApplicationType = webApplicationType;
+ this.webServerFactoryClass = webServerFactoryClass;
+ this.autoConfigurationClasses = autoConfigurationClasses;
+ }
+
+ public ConfigurableApplicationContext createManagementContext(ApplicationContext parentContext) {
+ ConfigurableApplicationContext managementContext = ApplicationContextFactory.DEFAULT
+ .create(this.webApplicationType);
+ managementContext.setParent(parentContext);
+ return managementContext;
+ }
+
+ public void registerWebServerFactoryBeans(ApplicationContext parentContext,
+ ConfigurableApplicationContext managementContext, AnnotationConfigRegistry registry) {
+ registry.register(this.autoConfigurationClasses);
+ registerWebServerFactoryFromParent(parentContext, managementContext);
+ }
+
+ private void registerWebServerFactoryFromParent(ApplicationContext parentContext,
+ ConfigurableApplicationContext managementContext) {
+ try {
+ if (managementContext.getBeanFactory() instanceof BeanDefinitionRegistry registry) {
+ registry.registerBeanDefinition("ManagementContextWebServerFactory",
+ new RootBeanDefinition(determineWebServerFactoryClass(parentContext)));
+ }
+ }
+ catch (NoSuchBeanDefinitionException ex) {
+ // Ignore and assume auto-configuration
+ }
+ }
+
+ private Class> determineWebServerFactoryClass(ApplicationContext parent) throws NoSuchBeanDefinitionException {
+ Class> factoryClass = parent.getBean(this.webServerFactoryClass).getClass();
+ if (cannotBeInstantiated(factoryClass)) {
+ throw new FatalBeanException("ManagementContextWebServerFactory implementation " + factoryClass.getName()
+ + " cannot be instantiated. To allow a separate management port to be used, a top-level class "
+ + "or static inner class should be used instead");
+ }
+ return factoryClass;
+ }
+
+ private boolean cannotBeInstantiated(Class> factoryClass) {
+ return factoryClass.isLocalClass()
+ || (factoryClass.isMemberClass() && !Modifier.isStatic(factoryClass.getModifiers()))
+ || factoryClass.isAnonymousClass();
+ }
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.java
index 59b6b3ea86..9b683bee2d 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.java
@@ -18,11 +18,15 @@ package org.springframework.boot.actuate.autoconfigure.web.reactive;
import reactor.core.publisher.Flux;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.actuate.autoconfigure.web.ManagementContextFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
+import org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration;
+import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.annotation.Bean;
/**
@@ -38,8 +42,9 @@ import org.springframework.context.annotation.Bean;
public class ReactiveManagementContextAutoConfiguration {
@Bean
- public ReactiveManagementContextFactory reactiveWebChildContextFactory() {
- return new ReactiveManagementContextFactory();
+ public ManagementContextFactory reactiveWebChildContextFactory() {
+ return new ManagementContextFactory(WebApplicationType.REACTIVE, ReactiveWebServerFactory.class,
+ ReactiveWebServerFactoryAutoConfiguration.class);
}
}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactory.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactory.java
deleted file mode 100644
index 431ec29b63..0000000000
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextFactory.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2012-2019 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
- *
- * https://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.boot.actuate.autoconfigure.web.reactive;
-
-import java.lang.reflect.Modifier;
-
-import org.springframework.beans.FatalBeanException;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.boot.actuate.autoconfigure.web.ManagementContextFactory;
-import org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration;
-import org.springframework.boot.web.context.ConfigurableWebServerApplicationContext;
-import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
-import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.util.ObjectUtils;
-
-/**
- * A {@link ManagementContextFactory} for reactive web applications.
- *
- * @author Andy Wilkinson
- */
-class ReactiveManagementContextFactory implements ManagementContextFactory {
-
- @Override
- public ConfigurableWebServerApplicationContext createManagementContext(ApplicationContext parent,
- Class>... configClasses) {
- AnnotationConfigReactiveWebServerApplicationContext child = new AnnotationConfigReactiveWebServerApplicationContext();
- child.setParent(parent);
- Class>[] combinedClasses = ObjectUtils.addObjectToArray(configClasses,
- ReactiveWebServerFactoryAutoConfiguration.class);
- child.register(combinedClasses);
- registerReactiveWebServerFactory(parent, child);
- return child;
- }
-
- private void registerReactiveWebServerFactory(ApplicationContext parent,
- AnnotationConfigReactiveWebServerApplicationContext childContext) {
- try {
- ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
- if (beanFactory instanceof BeanDefinitionRegistry) {
- BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
- registry.registerBeanDefinition("ReactiveWebServerFactory",
- new RootBeanDefinition(determineReactiveWebServerFactoryClass(parent)));
- }
- }
- catch (NoSuchBeanDefinitionException ex) {
- // Ignore and assume auto-configuration
- }
- }
-
- private Class> determineReactiveWebServerFactoryClass(ApplicationContext parent)
- throws NoSuchBeanDefinitionException {
- Class> factoryClass = parent.getBean(ReactiveWebServerFactory.class).getClass();
- if (cannotBeInstantiated(factoryClass)) {
- throw new FatalBeanException("ReactiveWebServerFactory implementation " + factoryClass.getName()
- + " cannot be instantiated. To allow a separate management port to be used, a top-level class "
- + "or static inner class should be used instead");
- }
- return factoryClass;
- }
-
- private boolean cannotBeInstantiated(Class> factoryClass) {
- return factoryClass.isLocalClass()
- || (factoryClass.isMemberClass() && !Modifier.isStatic(factoryClass.getModifiers()))
- || factoryClass.isAnonymousClass();
- }
-
-}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java
new file mode 100644
index 0000000000..9e4335e224
--- /dev/null
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ChildManagementContextInitializer.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2012-2022 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
+ *
+ * https://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.boot.actuate.autoconfigure.web.server;
+
+import java.util.List;
+
+import javax.lang.model.element.Modifier;
+
+import org.springframework.aot.generate.GeneratedMethod;
+import org.springframework.aot.generate.GenerationContext;
+import org.springframework.aot.generate.MethodReference;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
+import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
+import org.springframework.beans.factory.aot.BeanRegistrationCode;
+import org.springframework.beans.factory.aot.BeanRegistrationExcludeFilter;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.support.RegisteredBean;
+import org.springframework.boot.AotProcessor;
+import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor;
+import org.springframework.boot.actuate.autoconfigure.web.ManagementContextFactory;
+import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
+import org.springframework.boot.context.event.ApplicationFailedEvent;
+import org.springframework.boot.web.context.ConfigurableWebServerApplicationContext;
+import org.springframework.boot.web.context.WebServerInitializedEvent;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigRegistry;
+import org.springframework.context.aot.ApplicationContextAotGenerator;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.javapoet.ClassName;
+import org.springframework.util.Assert;
+
+/**
+ * {@link ApplicationListener} used to initialize the management context when it's running
+ * on a different port.
+ *
+ * @author Andy Wilkinson
+ * @author Phillip Webb
+ */
+class ChildManagementContextInitializer implements ApplicationListener,
+ BeanRegistrationAotProcessor, BeanRegistrationExcludeFilter {
+
+ private final ManagementContextFactory managementContextFactory;
+
+ private final ApplicationContext parentContext;
+
+ private final ApplicationContextInitializer applicationContextInitializer;
+
+ ChildManagementContextInitializer(ManagementContextFactory managementContextFactory,
+ ApplicationContext parentContext) {
+ this(managementContextFactory, parentContext, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ private ChildManagementContextInitializer(ManagementContextFactory managementContextFactory,
+ ApplicationContext parentContext,
+ ApplicationContextInitializer extends ConfigurableApplicationContext> applicationContextInitializer) {
+ this.managementContextFactory = managementContextFactory;
+ this.parentContext = parentContext;
+ this.applicationContextInitializer = (ApplicationContextInitializer) applicationContextInitializer;
+ }
+
+ @Override
+ public void onApplicationEvent(WebServerInitializedEvent event) {
+ if (event.getApplicationContext().equals(this.parentContext)) {
+ ConfigurableApplicationContext managementContext = createManagementContext();
+ registerBeans(managementContext);
+ managementContext.refresh();
+ }
+ }
+
+ @Override
+ public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
+ Assert.isInstanceOf(ConfigurableApplicationContext.class, this.parentContext);
+ BeanFactory parentBeanFactory = ((ConfigurableApplicationContext) this.parentContext).getBeanFactory();
+ if (registeredBean.getBeanClass().equals(getClass())
+ && registeredBean.getBeanFactory().equals(parentBeanFactory)) {
+ AotProcessor activeAotProcessor = AotProcessor.getActive(this.parentContext);
+ ConfigurableApplicationContext managementContext = createManagementContext();
+ registerBeans(managementContext);
+ return new AotContribution(activeAotProcessor, managementContext);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isExcluded(RegisteredBean registeredBean) {
+ return false;
+ }
+
+ private void registerBeans(ConfigurableApplicationContext managementContext) {
+ if (this.applicationContextInitializer != null) {
+ this.applicationContextInitializer.initialize(managementContext);
+ return;
+ }
+ Assert.isInstanceOf(AnnotationConfigRegistry.class, managementContext);
+ AnnotationConfigRegistry registry = (AnnotationConfigRegistry) managementContext;
+ this.managementContextFactory.registerWebServerFactoryBeans(this.parentContext, managementContext, registry);
+ registry.register(EnableChildManagementContextConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
+ if (isLazyInitialization()) {
+ managementContext.addBeanFactoryPostProcessor(new LazyInitializationBeanFactoryPostProcessor());
+ }
+ }
+
+ protected final ConfigurableApplicationContext createManagementContext() {
+ ConfigurableApplicationContext managementContext = this.managementContextFactory
+ .createManagementContext(this.parentContext);
+ managementContext.setId(this.parentContext.getId() + ":management");
+ if (managementContext instanceof ConfigurableWebServerApplicationContext webServerApplicationContext) {
+ webServerApplicationContext.setServerNamespace("management");
+ }
+ if (managementContext instanceof DefaultResourceLoader resourceLoader) {
+ resourceLoader.setClassLoader(this.parentContext.getClassLoader());
+ }
+ CloseManagementContextListener.addIfPossible(this.parentContext, managementContext);
+ return managementContext;
+ }
+
+ private boolean isLazyInitialization() {
+ AbstractApplicationContext context = (AbstractApplicationContext) this.parentContext;
+ List postProcessors = context.getBeanFactoryPostProcessors();
+ return postProcessors.stream().anyMatch(LazyInitializationBeanFactoryPostProcessor.class::isInstance);
+ }
+
+ ChildManagementContextInitializer withApplicationContextInitializer(
+ ApplicationContextInitializer extends ConfigurableApplicationContext> applicationContextInitializer) {
+ return new ChildManagementContextInitializer(this.managementContextFactory, this.parentContext,
+ applicationContextInitializer);
+ }
+
+ /**
+ * {@link BeanRegistrationAotContribution} for
+ * {@link ChildManagementContextInitializer}.
+ */
+ private static class AotContribution implements BeanRegistrationAotContribution {
+
+ private final AotProcessor activeAotProcessor;
+
+ private final GenericApplicationContext managementContext;
+
+ AotContribution(AotProcessor activeAotProcessor, ConfigurableApplicationContext managementContext) {
+ Assert.isInstanceOf(GenericApplicationContext.class, managementContext);
+ this.activeAotProcessor = activeAotProcessor;
+ this.managementContext = (GenericApplicationContext) managementContext;
+ }
+
+ @Override
+ public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) {
+ Class> target = (this.activeAotProcessor != null) ? this.activeAotProcessor.getApplication() : null;
+ ClassName generatedInitializerClassName = generationContext.getClassNameGenerator()
+ .generateClassName(target, "ManagementContextRegistrations");
+ new ApplicationContextAotGenerator().generateApplicationContext(this.managementContext, target,
+ "Management", generationContext, generatedInitializerClassName);
+ GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethodGenerator()
+ .generateMethod("addManagementInitializer").using((builder) -> {
+ builder.addJavadoc("Use AOT management context initialization");
+ builder.addModifiers(Modifier.PRIVATE, Modifier.STATIC);
+ builder.addParameter(RegisteredBean.class, "registeredBean");
+ builder.addParameter(ChildManagementContextInitializer.class, "instance");
+ builder.returns(ChildManagementContextInitializer.class);
+ builder.addStatement("return instance.withApplicationContextInitializer(new $L())",
+ generatedInitializerClassName);
+ });
+ beanRegistrationCode.addInstancePostProcessor(
+ MethodReference.ofStatic(beanRegistrationCode.getClassName(), postProcessorMethod.getName()));
+ }
+
+ }
+
+ /**
+ * {@link ApplicationListener} to propagate the {@link ContextClosedEvent} and
+ * {@link ApplicationFailedEvent} from a parent to a child.
+ */
+ private static class CloseManagementContextListener implements ApplicationListener {
+
+ private final ApplicationContext parentContext;
+
+ private final ConfigurableApplicationContext childContext;
+
+ CloseManagementContextListener(ApplicationContext parentContext, ConfigurableApplicationContext childContext) {
+ this.parentContext = parentContext;
+ this.childContext = childContext;
+ }
+
+ @Override
+ public void onApplicationEvent(ApplicationEvent event) {
+ if (event instanceof ContextClosedEvent) {
+ onContextClosedEvent((ContextClosedEvent) event);
+ }
+ if (event instanceof ApplicationFailedEvent) {
+ onApplicationFailedEvent((ApplicationFailedEvent) event);
+ }
+ }
+
+ private void onContextClosedEvent(ContextClosedEvent event) {
+ propagateCloseIfNecessary(event.getApplicationContext());
+ }
+
+ private void onApplicationFailedEvent(ApplicationFailedEvent event) {
+ propagateCloseIfNecessary(event.getApplicationContext());
+ }
+
+ private void propagateCloseIfNecessary(ApplicationContext applicationContext) {
+ if (applicationContext == this.parentContext) {
+ this.childContext.close();
+ }
+ }
+
+ static void addIfPossible(ApplicationContext parentContext, ConfigurableApplicationContext childContext) {
+ if (parentContext instanceof ConfigurableApplicationContext) {
+ add((ConfigurableApplicationContext) parentContext, childContext);
+ }
+ }
+
+ private static void add(ConfigurableApplicationContext parentContext,
+ ConfigurableApplicationContext childContext) {
+ parentContext.addApplicationListener(new CloseManagementContextListener(parentContext, childContext));
+ }
+
+ }
+
+}
diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java
index 7e4592eac3..051c558ae5 100644
--- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java
@@ -16,34 +16,21 @@
package org.springframework.boot.actuate.autoconfigure.web.server;
-import java.util.List;
-
import org.springframework.beans.factory.SmartInitializingSingleton;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextFactory;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
-import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.boot.web.context.ConfigurableWebServerApplicationContext;
-import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.event.ContextClosedEvent;
-import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertySource;
-import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.util.Assert;
/**
@@ -98,7 +85,7 @@ public class ManagementContextAutoConfiguration {
* @param environment the environment
*/
private void addLocalManagementPortPropertyAlias(ConfigurableEnvironment environment) {
- environment.getPropertySources().addLast(new PropertySource