use of org.openmrs.module.ModuleClassLoader in project openmrs-core by openmrs.
the class MutableResourceBundleMessageSource method findPropertiesFiles.
/**
* Searches the filesystem for message properties files. ABKTODO: consider caching this, rather
* than searching every time
*
* @return an array of property file names
*/
private Resource[] findPropertiesFiles() {
Set<Resource> resourceSet = new HashSet<>();
try {
String pattern = "classpath*:messages*.properties";
ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(OpenmrsClassLoader.getInstance());
Resource[] propertiesFiles = resourceResolver.getResources(pattern);
Collections.addAll(resourceSet, propertiesFiles);
for (ModuleClassLoader moduleClassLoader : ModuleFactory.getModuleClassLoaders()) {
resourceResolver = new PathMatchingResourcePatternResolver(moduleClassLoader);
propertiesFiles = resourceResolver.getResources(pattern);
Collections.addAll(resourceSet, propertiesFiles);
}
} catch (IOException e) {
log.error("Error generated", e);
}
if (log.isWarnEnabled() && (resourceSet.isEmpty())) {
log.warn("No properties files found.");
}
return resourceSet.toArray(new Resource[resourceSet.size()]);
}
Aggregations