use of org.springframework.boot.context.properties.bind.PlaceholdersResolver in project spring-boot by spring-projects.
the class EnvironmentEndpoint method getPropertySourceDescriptors.
private Map<String, PropertyValueDescriptor> getPropertySourceDescriptors(String propertyName) {
Map<String, PropertyValueDescriptor> propertySources = new LinkedHashMap<>();
PlaceholdersResolver resolver = getResolver();
getPropertySourcesAsMap().forEach((sourceName, source) -> propertySources.put(sourceName, source.containsProperty(propertyName) ? describeValueOf(propertyName, source, resolver) : null));
return propertySources;
}
use of org.springframework.boot.context.properties.bind.PlaceholdersResolver in project spring-boot by spring-projects.
the class ConfigDataEnvironment method getIncludedProfiles.
private Collection<? extends String> getIncludedProfiles(ConfigDataEnvironmentContributors contributors, ConfigDataActivationContext activationContext) {
PlaceholdersResolver placeholdersResolver = new ConfigDataEnvironmentContributorPlaceholdersResolver(contributors, activationContext, null, true);
Set<String> result = new LinkedHashSet<>();
for (ConfigDataEnvironmentContributor contributor : contributors) {
ConfigurationPropertySource source = contributor.getConfigurationPropertySource();
if (source != null && !contributor.hasConfigDataOption(ConfigData.Option.IGNORE_PROFILES)) {
Binder binder = new Binder(Collections.singleton(source), placeholdersResolver);
binder.bind(Profiles.INCLUDE_PROFILES, STRING_LIST).ifBound((includes) -> {
if (!contributor.isActive(activationContext)) {
InactiveConfigDataAccessException.throwIfPropertyFound(contributor, Profiles.INCLUDE_PROFILES);
InactiveConfigDataAccessException.throwIfPropertyFound(contributor, Profiles.INCLUDE_PROFILES.append("[0]"));
}
result.addAll(includes);
});
}
}
return result;
}
use of org.springframework.boot.context.properties.bind.PlaceholdersResolver in project spring-boot by spring-projects.
the class ConfigDataEnvironmentContributor method withBoundProperties.
/**
* Create a new {@link ConfigDataEnvironmentContributor} with bound
* {@link ConfigDataProperties}.
* @param contributors the contributors used for binding
* @param activationContext the activation context
* @return a new contributor instance
*/
ConfigDataEnvironmentContributor withBoundProperties(Iterable<ConfigDataEnvironmentContributor> contributors, ConfigDataActivationContext activationContext) {
Iterable<ConfigurationPropertySource> sources = Collections.singleton(getConfigurationPropertySource());
PlaceholdersResolver placeholdersResolver = new ConfigDataEnvironmentContributorPlaceholdersResolver(contributors, activationContext, this, true);
Binder binder = new Binder(sources, placeholdersResolver, null, null, null);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
if (properties != null && this.configDataOptions.contains(ConfigData.Option.IGNORE_IMPORTS)) {
properties = properties.withoutImports();
}
return new ConfigDataEnvironmentContributor(Kind.BOUND_IMPORT, this.location, this.resource, this.fromProfileSpecificImport, this.propertySource, this.configurationPropertySource, properties, this.configDataOptions, null);
}
use of org.springframework.boot.context.properties.bind.PlaceholdersResolver in project spring-boot by spring-projects.
the class ConfigDataEnvironmentContributors method getBinder.
private Binder getBinder(ConfigDataActivationContext activationContext, Predicate<ConfigDataEnvironmentContributor> filter, Set<BinderOption> options) {
boolean failOnInactiveSource = options.contains(BinderOption.FAIL_ON_BIND_TO_INACTIVE_SOURCE);
Iterable<ConfigurationPropertySource> sources = () -> getBinderSources(filter.and((contributor) -> failOnInactiveSource || contributor.isActive(activationContext)));
PlaceholdersResolver placeholdersResolver = new ConfigDataEnvironmentContributorPlaceholdersResolver(this.root, activationContext, null, failOnInactiveSource);
BindHandler bindHandler = !failOnInactiveSource ? null : new InactiveSourceChecker(activationContext);
return new Binder(sources, placeholdersResolver, null, null, bindHandler);
}
use of org.springframework.boot.context.properties.bind.PlaceholdersResolver in project spring-boot by spring-projects.
the class EnvironmentEndpoint method getEnvironmentDescriptor.
private EnvironmentDescriptor getEnvironmentDescriptor(Predicate<String> propertyNamePredicate) {
PlaceholdersResolver resolver = getResolver();
List<PropertySourceDescriptor> propertySources = new ArrayList<>();
getPropertySourcesAsMap().forEach((sourceName, source) -> {
if (source instanceof EnumerablePropertySource) {
propertySources.add(describeSource(sourceName, (EnumerablePropertySource<?>) source, resolver, propertyNamePredicate));
}
});
return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()), propertySources);
}
Aggregations