Example usage for org.springframework.util MultiValueMap addAll

List of usage examples for org.springframework.util MultiValueMap addAll

Introduction

In this page you can find the example usage for org.springframework.util MultiValueMap addAll.

Prototype

void addAll(K key, List<? extends V> values);

Source Link

Document

Add all the values of the given list to the current list of values for the given key.

Usage

From source file:org.springframework.core.io.support.SpringFactoriesLoader.java

private static Map<String, List<String>> loadSpringFactories(@Nullable ClassLoader classLoader) {
    MultiValueMap<String, String> result = cache.get(classLoader);
    if (result != null)
        return result;
    try {/* w ww  .  j  a  va 2s  .co  m*/
        Enumeration<URL> urls = (classLoader != null ? classLoader.getResources(FACTORIES_RESOURCE_LOCATION)
                : ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));
        result = new LinkedMultiValueMap<>();
        while (urls.hasMoreElements()) {
            URL url = urls.nextElement();
            UrlResource resource = new UrlResource(url);
            Properties properties = PropertiesLoaderUtils.loadProperties(resource);
            for (Map.Entry<?, ?> entry : properties.entrySet()) {
                List<String> factoryClassNames = Arrays
                        .asList(StringUtils.commaDelimitedListToStringArray((String) entry.getValue()));
                result.addAll((String) entry.getKey(), factoryClassNames);
            }
        }
        cache.put(classLoader, result);
        return result;
    } catch (IOException ex) {
        throw new IllegalArgumentException(
                "Unable to load factories from location [" + FACTORIES_RESOURCE_LOCATION + "]", ex);
    }
}