Merge branch '2.7.x'
This commit is contained in:
commit
03e5dcdb3a
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
|
|
@ -31,9 +31,7 @@ import org.springframework.core.annotation.Order;
|
|||
/**
|
||||
* Specialized {@link Configuration @Configuration} class that defines configuration
|
||||
* specific for the management context. Configurations should be registered in
|
||||
* {@code /META-INF/spring.factories} under the
|
||||
* {@code org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration}
|
||||
* key.
|
||||
* {@code /META-INF/spring/org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration.imports}.
|
||||
* <p>
|
||||
* {@code ManagementContextConfiguration} classes can be ordered using
|
||||
* {@link Order @Order}. Ordering by implementing {@link Ordered} is not supported and
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
|||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
|
||||
import org.springframework.boot.context.annotation.ImportCandidates;
|
||||
import org.springframework.context.annotation.DeferredImportSelector;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.Ordered;
|
||||
|
|
@ -36,14 +37,15 @@ import org.springframework.util.StringUtils;
|
|||
|
||||
/**
|
||||
* Selects configuration classes for the management context configuration. Entries are
|
||||
* loaded from {@code /META-INF/spring.factories} under the
|
||||
* {@code org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration}
|
||||
* key.
|
||||
* loaded from
|
||||
* {@code /META-INF/spring/org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration.imports}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Moritz Halbritter
|
||||
* @see ManagementContextConfiguration
|
||||
* @see ImportCandidates
|
||||
*/
|
||||
@Order(Ordered.LOWEST_PRECEDENCE)
|
||||
class ManagementContextConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware {
|
||||
|
|
@ -88,7 +90,10 @@ class ManagementContextConfigurationImportSelector implements DeferredImportSele
|
|||
}
|
||||
|
||||
protected List<String> loadFactoryNames() {
|
||||
return SpringFactoriesLoader.loadFactoryNames(ManagementContextConfiguration.class, this.classLoader);
|
||||
List<String> factoryNames = new ArrayList<>(
|
||||
SpringFactoriesLoader.loadFactoryNames(ManagementContextConfiguration.class, this.classLoader));
|
||||
ImportCandidates.load(ManagementContextConfiguration.class, this.classLoader).forEach(factoryNames::add);
|
||||
return factoryNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,11 +1,2 @@
|
|||
org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=\
|
||||
org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive.WebFluxEndpointManagementContextConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.security.servlet.SecurityRequestMatchersManagementContextConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementChildContextConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementChildContextConfiguration,\
|
||||
org.springframework.boot.actuate.autoconfigure.web.servlet.WebMvcEndpointChildContextConfiguration
|
||||
|
||||
org.springframework.boot.diagnostics.FailureAnalyzer=\
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.ValidationFailureAnalyzer
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive.WebFluxEndpointManagementContextConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.security.servlet.SecurityRequestMatchersManagementContextConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementChildContextConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementChildContextConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.web.servlet.WebMvcEndpointChildContextConfiguration
|
||||
|
|
@ -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,7 +16,9 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure.web.server;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
|
@ -24,6 +26,7 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
|
||||
import org.springframework.boot.context.annotation.ImportCandidates;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
|
||||
|
|
@ -58,6 +61,18 @@ class ManagementContextConfigurationImportSelectorTests {
|
|||
assertThat(imports).containsExactlyInAnyOrder(ChildOnly.class.getName(), A.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectImportsLoadsFromResources() {
|
||||
String[] imports = new ManagementContextConfigurationImportSelector()
|
||||
.selectImports(AnnotationMetadata.introspect(EnableChildContext.class));
|
||||
Set<String> expected = new HashSet<>();
|
||||
ImportCandidates
|
||||
.load(ManagementContextConfiguration.class,
|
||||
ManagementContextConfigurationImportSelectorTests.class.getClassLoader())
|
||||
.forEach(expected::add);
|
||||
assertThat(imports).containsExactlyInAnyOrderElementsOf(expected);
|
||||
}
|
||||
|
||||
private static final class TestManagementContextConfigurationsImportSelector
|
||||
extends ManagementContextConfigurationImportSelector {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.boot.context.annotation.ImportCandidates;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* Import and apply the specified auto-configuration classes. Applies the same ordering
|
||||
* rules as {@code @EnableAutoConfiguration} but restricts the auto-configuration classes
|
||||
* to the specified set, rather than consulting {@code spring.factories}.
|
||||
* to the specified set, rather than consulting {@link ImportCandidates}.
|
||||
* <p>
|
||||
* Can also be used to {@link #exclude()} specific auto-configuration classes such that
|
||||
* they will never be applied.
|
||||
|
|
|
|||
Loading…
Reference in New Issue