- private static Map<String, List<String>> loadSpringFactories(ClassLoader classLoader) {
- Map<String, List<String>> result = (Map)cache.get(classLoader);
- if (result != null) {
- return result;
- } else {
- HashMap result = new HashMap();
- try {
- Enumeration urls = classLoader.getResources("META-INF/spring.factories");
- while(urls.hasMoreElements()) {
- URL url = (URL)urls.nextElement();
- UrlResource resource = new UrlResource(url);
- Properties properties = PropertiesLoaderUtils.loadProperties(resource);
- Iterator var6 = properties.entrySet().iterator();
- while(var6.hasNext()) {
- Map.Entry<?, ?> entry = (Map.Entry)var6.next();
- String factoryTypeName = ((String)entry.getKey()).trim();
- String[] factoryImplementationNames = StringUtils.commaDelimitedListToStringArray((String)entry.getValue());
- String[] var10 = factoryImplementationNames;
- int var11 = factoryImplementationNames.length;
- for(int var12 = 0; var12 < var11; ++var12) {
- String factoryImplementationName = var10[var12];
- ((List)result.computeIfAbsent(factoryTypeName, (key) -> {
- return new ArrayList();
- })).add(factoryImplementationName.trim());
- }
- }
- }
- result.replaceAll((factoryType, implementations) -> {
- return (List)implementations.stream().distinct().collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
- });
- cache.put(classLoader, result);
- return result;
- } catch (IOException var14) {
- throw new IllegalArgumentException("Unable to load factories from location [META-INF/spring.factories]", var14);
- }
- }
- }
posted @
2022-05-06 23:23
小强哥in
阅读(
18)
评论()
编辑
收藏
举报