|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2014 the original author or authors.
|
|
|
|
|
* Copyright 2012-2015 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.
|
|
|
|
@ -18,12 +18,10 @@ package org.springframework.boot.autoconfigure;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -56,15 +54,11 @@ class AutoConfigurationSorter {
|
|
|
|
|
|
|
|
|
|
public List<String> getInPriorityOrder(Collection<String> classNames)
|
|
|
|
|
throws IOException {
|
|
|
|
|
|
|
|
|
|
final AutoConfigurationClasses classes = new AutoConfigurationClasses(
|
|
|
|
|
this.metadataReaderFactory, classNames);
|
|
|
|
|
|
|
|
|
|
List<String> orderedClassNames = new ArrayList<String>(classNames);
|
|
|
|
|
|
|
|
|
|
// Initially sort alphabetically
|
|
|
|
|
Collections.sort(orderedClassNames);
|
|
|
|
|
|
|
|
|
|
// Then sort by order
|
|
|
|
|
Collections.sort(orderedClassNames, new Comparator<String>() {
|
|
|
|
|
@Override
|
|
|
|
@ -74,12 +68,9 @@ class AutoConfigurationSorter {
|
|
|
|
|
return (i1 < i2) ? -1 : (i1 > i2) ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Then respect @AutoConfigureBefore @AutoConfigureAfter
|
|
|
|
|
orderedClassNames = sortByAnnotation(classes, orderedClassNames);
|
|
|
|
|
|
|
|
|
|
return orderedClassNames;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> sortByAnnotation(AutoConfigurationClasses classes,
|
|
|
|
@ -170,7 +161,10 @@ class AutoConfigurationSorter {
|
|
|
|
|
if (attributes == null) {
|
|
|
|
|
return Collections.emptySet();
|
|
|
|
|
}
|
|
|
|
|
return new HashSet<String>(Arrays.asList((String[]) attributes.get("value")));
|
|
|
|
|
Set<String> value = new LinkedHashSet<String>();
|
|
|
|
|
Collections.addAll(value, (String[]) attributes.get("value"));
|
|
|
|
|
Collections.addAll(value, (String[]) attributes.get("name"));
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|