use of org.springframework.boot.context.config.ConfigDataResourceNotFoundException in project spring-cloud-zookeeper by spring-cloud.
the class ZookeeperConfigDataLoader method load.
@Override
public ConfigData load(ConfigDataLoaderContext context, ZookeeperConfigDataResource resource) {
try {
CuratorFramework curator = context.getBootstrapContext().get(CuratorFramework.class);
if (curator == null) {
// this can happen if certain conditions are met
return null;
}
ZookeeperPropertySource propertySource = new ZookeeperPropertySource(resource.getContext(), curator);
List<ZookeeperPropertySource> propertySources = Collections.singletonList(propertySource);
return new ConfigData(propertySources, source -> {
List<ConfigData.Option> options = new ArrayList<>();
options.add(ConfigData.Option.IGNORE_IMPORTS);
options.add(ConfigData.Option.IGNORE_PROFILES);
if (StringUtils.hasText(resource.getProfile())) {
options.add(ConfigData.Option.PROFILE_SPECIFIC);
}
return ConfigData.Options.of(options.toArray(new ConfigData.Option[0]));
});
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Error getting properties from zookeeper: " + resource, e);
}
throw new ConfigDataResourceNotFoundException(resource, e);
}
}
use of org.springframework.boot.context.config.ConfigDataResourceNotFoundException in project spring-cloud-aws by awspring.
the class AwsSecretsManagerConfigDataLoader method load.
@Override
public ConfigData load(ConfigDataLoaderContext context, AwsSecretsManagerConfigDataResource resource) {
try {
AWSSecretsManager sm = context.getBootstrapContext().get(AWSSecretsManager.class);
AwsSecretsManagerPropertySource propertySource = resource.getPropertySources().createPropertySource(resource.getContext(), resource.isOptional(), sm);
if (propertySource != null) {
return new ConfigData(Collections.singletonList(propertySource));
} else {
return null;
}
} catch (Exception e) {
throw new ConfigDataResourceNotFoundException(resource, e);
}
}
use of org.springframework.boot.context.config.ConfigDataResourceNotFoundException in project spring-cloud-aws by awspring.
the class ParameterStoreConfigDataLoader method load.
@Override
@Nullable
public ConfigData load(ConfigDataLoaderContext context, ParameterStoreConfigDataResource resource) {
try {
SsmClient ssm = context.getBootstrapContext().get(SsmClient.class);
ParameterStorePropertySource propertySource = resource.getPropertySources().createPropertySource(resource.getContext(), resource.isOptional(), ssm);
if (propertySource != null) {
return new ConfigData(Collections.singletonList(propertySource));
} else {
return null;
}
} catch (Exception e) {
throw new ConfigDataResourceNotFoundException(resource, e);
}
}
use of org.springframework.boot.context.config.ConfigDataResourceNotFoundException in project spring-cloud-consul by spring-cloud.
the class ConsulConfigDataLoader method doLoad.
public ConfigData doLoad(ConfigDataLoaderContext context, ConsulConfigDataResource resource) {
try {
ConsulClient consul = getBean(context, ConsulClient.class);
ConsulConfigIndexes indexes = getBean(context, ConsulConfigIndexes.class);
ConsulPropertySource propertySource = resource.getConsulPropertySources().createPropertySource(resource.getContext(), consul, indexes.getIndexes()::put);
if (propertySource == null) {
return null;
}
List<ConsulPropertySource> propertySources = Collections.singletonList(propertySource);
if (ALL_OPTIONS.size() == 1) {
// boot 2.4.2 and prior
return new ConfigData(propertySources);
} else if (ALL_OPTIONS.size() == 2) {
// boot 2.4.3 and 2.4.4
return new ConfigData(propertySources, Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
} else if (ALL_OPTIONS.size() > 2) {
// boot 2.4.5+
return new ConfigData(propertySources, source -> {
List<Option> options = new ArrayList<>();
options.add(Option.IGNORE_IMPORTS);
options.add(Option.IGNORE_PROFILES);
if (StringUtils.hasText(resource.getProfile())) {
options.add(Option.PROFILE_SPECIFIC);
}
return Options.of(options.toArray(new Option[0]));
});
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Error getting properties from consul: " + resource, e);
}
throw new ConfigDataResourceNotFoundException(resource, e);
}
return null;
}
use of org.springframework.boot.context.config.ConfigDataResourceNotFoundException in project spring-cloud-aws by awspring.
the class SecretsManagerConfigDataLoader method load.
@Override
@Nullable
public ConfigData load(ConfigDataLoaderContext context, SecretsManagerConfigDataResource resource) {
try {
SecretsManagerClient sm = context.getBootstrapContext().get(SecretsManagerClient.class);
SecretsManagerPropertySource propertySource = resource.getPropertySources().createPropertySource(resource.getContext(), resource.isOptional(), sm);
if (propertySource != null) {
return new ConfigData(Collections.singletonList(propertySource));
} else {
return null;
}
} catch (Exception e) {
throw new ConfigDataResourceNotFoundException(resource, e);
}
}
Aggregations