use of io.micronaut.core.io.file.DefaultFileSystemResourceLoader in project micronaut-core by micronaut-projects.
the class DefaultEnvironment method readPropertySourceList.
/**
* @param name The name to resolver property sources
* @return The list of property sources
*/
protected List<PropertySource> readPropertySourceList(String name) {
List<PropertySource> propertySources = new ArrayList<>();
for (String configLocation : configLocations) {
ResourceLoader resourceLoader;
if (configLocation.equals("classpath:/")) {
resourceLoader = this;
} else if (configLocation.startsWith("classpath:")) {
resourceLoader = this.forBase(configLocation);
} else if (configLocation.startsWith("file:")) {
configLocation = configLocation.substring(5);
Path configLocationPath = Paths.get(configLocation);
if (Files.exists(configLocationPath) && Files.isDirectory(configLocationPath) && Files.isReadable(configLocationPath)) {
resourceLoader = new DefaultFileSystemResourceLoader(configLocationPath);
} else {
// Skip not existing config location
continue;
}
} else {
throw new ConfigurationException("Unsupported config location format: " + configLocation);
}
readPropertySourceList(name, resourceLoader, propertySources);
}
return propertySources;
}
use of io.micronaut.core.io.file.DefaultFileSystemResourceLoader in project micronaut-maven-plugin by micronaut-projects.
the class ApplicationConfigurationService method parseApplicationConfiguration.
private Map<String, Object> parseApplicationConfiguration() {
Map<String, Object> configuration = new HashMap<>();
PropertySourceLoader[] loaders = { new YamlPropertySourceLoader(), new PropertiesPropertySourceLoader() };
for (PropertySourceLoader loader : loaders) {
Optional<PropertySource> propertySource = loader.load("application", new DefaultFileSystemResourceLoader(new File(mavenProject.getBasedir(), "src/main/resources")));
if (propertySource.isPresent()) {
MapPropertySource mapPropertySource = (MapPropertySource) propertySource.get();
configuration.putAll(mapPropertySource.asMap());
}
}
MapPropertySource[] propertySources = { new EnvironmentPropertySource(), new SystemPropertiesPropertySource() };
for (MapPropertySource propertySource : propertySources) {
configuration.putAll(propertySource.asMap());
}
return configuration;
}
Aggregations