use of com.hotels.styx.infrastructure.configuration.yaml.JsonNodeConfig in project styx by ExpediaGroup.
the class ServiceProvision method servicesMap.
private static <U> Map<String, U> servicesMap(JsonNode jsonNode, Environment environment, Class<? extends U> serviceClass) {
JsonNode factories = jsonNode.get("factories");
JsonNodeConfig jsonNodeConfig = new JsonNodeConfig(factories);
return iteratorToList(factories.fieldNames()).stream().flatMap(name -> {
if (isType(name, jsonNodeConfig, SpiExtension.class)) {
return namedExtensionFromSpiExtension(environment, serviceClass, jsonNodeConfig, name);
} else if (isType(name, jsonNodeConfig, ServiceFactoryConfig.class)) {
return namedExtensionFromServiceFactoryConfig(environment, serviceClass, jsonNodeConfig, name);
} else {
String content = factories.get(name).toString();
String message = format("Unexpected configuration object 'services.factories.%s', Configuration='%s'", name, content);
throw new ConfigurationException(message);
}
}).collect(toMap(Pair::key, Pair::value));
}
Aggregations