Order ManagementContextConfiguration classes without loading them
Previously, ManagementContextConfiguration classes were loaded to allow them to be ordered based on either @Order or implementing Ordered. This had the unwanted side-effect of possibly logging unwanted INFO messages if the reflection-based annotation introspection failed. One cause of this was @ConditionalOnClass when the referenced class was not on the classpath. This commit uses the ASM-based annotation metadata reading to determine the order of a management context configuration class based on the @Order annotation. The classes are then sorted using a standard OrderComparator. Note that Ordering via implemented Ordered is not supported as it cannot be determine without loading the class.
This commit is contained in:
@@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link ManagementContextConfigurationsImportSelector}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ManagementContextConfigurationsImportSelectorTests {
|
||||
|
||||
@@ -37,7 +38,7 @@ public class ManagementContextConfigurationsImportSelectorTests {
|
||||
String[] imports = new TestManagementContextConfigurationsImportSelector()
|
||||
.selectImports(null);
|
||||
assertThat(imports).containsExactly(A.class.getName(), B.class.getName(),
|
||||
C.class.getName());
|
||||
C.class.getName(), D.class.getName());
|
||||
}
|
||||
|
||||
private static class TestManagementContextConfigurationsImportSelector
|
||||
@@ -45,7 +46,8 @@ public class ManagementContextConfigurationsImportSelectorTests {
|
||||
|
||||
@Override
|
||||
protected List<String> loadFactoryNames() {
|
||||
return Arrays.asList(C.class.getName(), A.class.getName(), B.class.getName());
|
||||
return Arrays.asList(C.class.getName(), A.class.getName(), D.class.getName(),
|
||||
B.class.getName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,4 +67,8 @@ public class ManagementContextConfigurationsImportSelectorTests {
|
||||
|
||||
}
|
||||
|
||||
static class D {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user