use of io.micronaut.core.io.scan.DefaultClassPathResourceLoader in project micronaut-aot by micronaut-projects.
the class YamlPropertySourceGenerator method createMapProperty.
private void createMapProperty(YamlPropertySourceLoader loader, AOTContext context, String resource) {
Optional<PropertySource> optionalSource = loader.load(resource, new DefaultClassPathResourceLoader(this.getClass().getClassLoader()));
if (optionalSource.isPresent()) {
LOGGER.info("Converting {} into Java based configuration", resource + ".yml");
context.registerExcludedResource(resource + ".yml");
context.registerExcludedResource(resource + ".yaml");
PropertySource ps = optionalSource.get();
if (ps instanceof MapPropertySource) {
MapPropertySource mps = (MapPropertySource) ps;
Map<String, Object> values = mps.asMap();
MapPropertySourceGenerator generator = new MapPropertySourceGenerator(resource, values);
generator.generate(context);
} else {
throw new UnsupportedOperationException("Unknown property source type:" + ps.getClass());
}
}
}
Aggregations