<b><font color="#f44336">AutoConfigurationImportSelector{<br></font></b>public String[] <font color="#f44336">selectImports</font>(AnnotationMetadata annotationMetadata) {<br> if (!this.isEnabled(annotationMetadata)) {<br> return NO_IMPORTS;<br> } else {<br> AutoConfigurationMetadata autoConfigurationMetadata = AutoConfigurationMetadataLoader.loadMetadata(this.beanClassLoader);<br> AnnotationAttributes attributes = this.getAttributes(annotationMetadata);<br> List<String> configurations = this.<font color="#f44336">getCandidateConfigurations</font>(annotationMetadata, attributes);<br> configurations = this.removeDuplicates(configurations);<br> Set<String> exclusions = this.getExclusions(annotationMetadata, attributes);<br> this.checkExcludedClasses(configurations, exclusions);<br> configurations.removeAll(exclusions);<br> configurations = this.filter(configurations, autoConfigurationMetadata);<br> this.fireAutoConfigurationImportEvents(configurations, exclusions);<br> return StringUtils.toStringArray(configurations);<br> }<br> }<br>protected List<String> <b><font color="#f44336">getCandidateConfigurations</font></b>(AnnotationMetadata metadata, AnnotationAttributes attributes) {<br> List<String> configurations = <font color="#f44336">SpringFactoriesLoader</font>.<b style=""><font color="#f44336">loadFactoryNames</font></b>(this.getSpringFactoriesLoaderFactoryClass(), this.getBeanClassLoader());<br> Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.");<br> return configurations;<br> }<br>}
<font color="#f44336">abstract</font> class <b><font color="#f44336">SpringFactoriesLoader</font></b>{<br>public static final String FACTORIES_RESOURCE_LOCATION = "<font color="#f44336">META-INF/spring.factories</font>";<br>public static List<String> <font color="#f44336">loadFactoryNames</font>(Class<?> factoryClass, @Nullable ClassLoader classLoader) {<br> String factoryClassName = factoryClass.getName();<br> return (List)<font color="#f44336">loadSpringFactories</font>(classLoader).getOrDefault(factoryClassName, Collections.emptyList());<br> }<br>private static Map<String, List<String>> <font color="#f44336">loadSpringFactories</font>(@Nullable ClassLoader classLoader) {<br> MultiValueMap<String, String> result = (MultiValueMap)cache.get(classLoader);<br> if (result != null) {<br> return result;<br> } else {<br> try {<br> Enumeration<URL> urls = classLoader != null ? classLoader.getResources("META-INF/spring.factories") : ClassLoader.getSystemResources("META-INF/spring.factories");<br> LinkedMultiValueMap result = new LinkedMultiValueMap();<br><br> while(urls.hasMoreElements()) {<br> URL url = (URL)urls.nextElement();<br> UrlResource resource = new UrlResource(url);<br> Properties properties = PropertiesLoaderUtils.loadProperties(resource);<br> Iterator var6 = properties.entrySet().iterator();<br><br> while(var6.hasNext()) {<br> Entry<?, ?> entry = (Entry)var6.next();<br> List<String> factoryClassNames = Arrays.asList(StringUtils.commaDelimitedListToStringArray((String)entry.getValue()));<br> result.addAll((String)entry.getKey(), factoryClassNames);<br> }<br> }<br><br> cache.put(classLoader, result);<br> return result;<br> } catch (IOException var9) {<br> throw new IllegalArgumentException("Unable to load factories from location [META-INF/spring.factories]", var9);<br> }<br> }<br> }<br><br>}<br>