use of org.springframework.cloud.consul.config.ConsulPropertySources.Context in project spring-cloud-consul by spring-cloud.
the class ConsulConfigDataLocationResolver method resolveProfileSpecific.
@Override
public List<ConsulConfigDataResource> resolveProfileSpecific(ConfigDataLocationResolverContext resolverContext, ConfigDataLocation location, Profiles profiles) throws ConfigDataLocationNotFoundException {
UriComponents locationUri = parseLocation(resolverContext, location);
// create consul client
registerBean(resolverContext, ConsulProperties.class, loadProperties(resolverContext, locationUri));
registerAndPromoteBean(resolverContext, ConsulClient.class, this::createConsulClient);
// create locations
ConsulConfigProperties properties = loadConfigProperties(resolverContext);
ConsulPropertySources consulPropertySources = new ConsulPropertySources(properties, log);
List<Context> contexts = (locationUri == null || CollectionUtils.isEmpty(locationUri.getPathSegments())) ? consulPropertySources.generateAutomaticContexts(profiles.getAccepted(), false) : getCustomContexts(locationUri, properties);
registerAndPromoteBean(resolverContext, ConsulConfigProperties.class, InstanceSupplier.of(properties));
registerAndPromoteBean(resolverContext, ConsulConfigIndexes.class, InstanceSupplier.from(ConsulConfigDataIndexes::new));
return contexts.stream().map(propertySourceContext -> new ConsulConfigDataResource(propertySourceContext.getPath(), properties, consulPropertySources, propertySourceContext.getProfile())).collect(Collectors.toList());
}
Aggregations