use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class OnEnabledEndpointCondition method determineEndpointOutcome.
private ConditionOutcome determineEndpointOutcome(String endpointName, boolean enabledByDefault, ConditionContext context) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "endpoints." + endpointName + ".");
if (resolver.containsProperty("enabled") || !enabledByDefault) {
boolean match = resolver.getProperty("enabled", Boolean.class, enabledByDefault);
ConditionMessage message = ConditionMessage.forCondition(ConditionalOnEnabledEndpoint.class, "(" + endpointName + ")").because(match ? "enabled" : "disabled");
return new ConditionOutcome(match, message);
}
return null;
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class OnEnabledEndpointCondition method determineAllEndpointsOutcome.
private ConditionOutcome determineAllEndpointsOutcome(ConditionContext context) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "endpoints.");
boolean match = Boolean.valueOf(resolver.getProperty("enabled", "true"));
ConditionMessage message = ConditionMessage.forCondition(ConditionalOnEnabledEndpoint.class).because("All endpoints are " + (match ? "enabled" : "disabled") + " by default");
return new ConditionOutcome(match, message);
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class CloudFoundryActuatorAutoConfiguration method getCloudFoundrySecurityService.
private CloudFoundrySecurityService getCloudFoundrySecurityService(RestTemplateBuilder restTemplateBuilder, Environment environment) {
RelaxedPropertyResolver cloudFoundryProperties = new RelaxedPropertyResolver(environment, "management.cloudfoundry.");
String cloudControllerUrl = environment.getProperty("vcap.application.cf_api");
boolean skipSslValidation = cloudFoundryProperties.getProperty("skip-ssl-validation", Boolean.class, false);
return cloudControllerUrl == null ? null : new CloudFoundrySecurityService(restTemplateBuilder, cloudControllerUrl, skipSslValidation);
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class AutoConfigurationImportSelector method getExcludeAutoConfigurationsProperty.
private List<String> getExcludeAutoConfigurationsProperty() {
if (getEnvironment() instanceof ConfigurableEnvironment) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(this.environment, "spring.autoconfigure.");
Map<String, Object> properties = resolver.getSubProperties("exclude");
if (properties.isEmpty()) {
return Collections.emptyList();
}
List<String> excludes = new ArrayList<>();
for (Map.Entry<String, Object> entry : properties.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
if (name.isEmpty() || name.startsWith("[") && value != null) {
excludes.addAll(new HashSet<>(Arrays.asList(StringUtils.tokenizeToStringArray(String.valueOf(value), ","))));
}
}
return excludes;
}
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(getEnvironment(), "spring.autoconfigure.");
String[] exclude = resolver.getProperty("exclude", String[].class);
return (Arrays.asList(exclude == null ? new String[0] : exclude));
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class CacheCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
String sourceClass = "";
if (metadata instanceof ClassMetadata) {
sourceClass = ((ClassMetadata) metadata).getClassName();
}
ConditionMessage.Builder message = ConditionMessage.forCondition("Cache", sourceClass);
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "spring.cache.");
if (!resolver.containsProperty("type")) {
return ConditionOutcome.match(message.because("automatic cache type"));
}
CacheType cacheType = CacheConfigurations.getType(((AnnotationMetadata) metadata).getClassName());
String value = resolver.getProperty("type").replace('-', '_').toUpperCase();
if (value.equals(cacheType.name())) {
return ConditionOutcome.match(message.because(value + " cache type"));
}
return ConditionOutcome.noMatch(message.because(value + " cache type"));
}
Aggregations