use of org.mule.runtime.core.internal.util.OrderedProperties in project mule by mulesoft.
the class PropertiesUtils method discoverProperties.
/**
* Discovers properties files available on the given classloader.
*
* @param classLoader classloader used to find properties resources. Not null.
* @param resource resource to find. Not empty
* @return a non null list of Properties
* @throws IOException when a property file cannot be processed
*/
public static List<Properties> discoverProperties(ClassLoader classLoader, String resource) throws IOException {
checkArgument(!isEmpty(resource), "Resource cannot be empty");
checkArgument(classLoader != null, "ClassLoader cannot be null");
List<Properties> result = new LinkedList<>();
Enumeration<URL> allPropertiesResources = classLoader.getResources(resource);
while (allPropertiesResources.hasMoreElements()) {
URL propertiesResource = allPropertiesResources.nextElement();
if (logger.isDebugEnabled()) {
logger.debug("Reading properties from: " + propertiesResource.toString());
}
Properties properties = new OrderedProperties();
try (InputStream resourceStream = propertiesResource.openStream()) {
properties.load(resourceStream);
}
result.add(properties);
}
return result;
}
Aggregations