Search in sources :

Example 1 with RelaxedPropertyResolver

use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.

the class SpringBootTestContextBootstrapper method getConfiguredWebApplicationType.

private WebApplicationType getConfiguredWebApplicationType(MergedContextConfiguration configuration) {
    PropertySources sources = convertToPropertySources(configuration.getPropertySourceProperties());
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(new PropertySourcesPropertyResolver(sources), "spring.main.");
    String property = resolver.getProperty("web-application-type");
    return (property != null ? WebApplicationType.valueOf(property.toUpperCase()) : null);
}
Also used : PropertySourcesPropertyResolver(org.springframework.core.env.PropertySourcesPropertyResolver) PropertySources(org.springframework.core.env.PropertySources) MutablePropertySources(org.springframework.core.env.MutablePropertySources) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Example 2 with RelaxedPropertyResolver

use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.

the class SpringPropertyAction method getValue.

private String getValue(String source, String defaultValue) {
    if (this.environment == null) {
        addWarn("No Spring Environment available to resolve " + source);
        return defaultValue;
    }
    String value = this.environment.getProperty(source);
    if (value != null) {
        return value;
    }
    int lastDot = source.lastIndexOf(".");
    if (lastDot > 0) {
        String prefix = source.substring(0, lastDot + 1);
        RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(this.environment, prefix);
        return resolver.getProperty(source.substring(lastDot + 1), defaultValue);
    }
    return defaultValue;
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Example 3 with RelaxedPropertyResolver

use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.

the class LoggingSystemProperties method apply.

public void apply(LogFile logFile) {
    RelaxedPropertyResolver propertyResolver = RelaxedPropertyResolver.ignoringUnresolvableNestedPlaceholders(this.environment, "logging.");
    setSystemProperty(propertyResolver, EXCEPTION_CONVERSION_WORD, "exception-conversion-word");
    setSystemProperty(propertyResolver, CONSOLE_LOG_PATTERN, "pattern.console");
    setSystemProperty(propertyResolver, FILE_LOG_PATTERN, "pattern.file");
    setSystemProperty(propertyResolver, LOG_LEVEL_PATTERN, "pattern.level");
    setSystemProperty(PID_KEY, new ApplicationPid().toString());
    if (logFile != null) {
        logFile.applyToSystemProperties();
    }
}
Also used : ApplicationPid(org.springframework.boot.ApplicationPid) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Example 4 with RelaxedPropertyResolver

use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.

the class LocalDebugPortAvailableCondition method getMatchOutcome.

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage.forCondition("Local Debug Port Condition");
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "spring.devtools.remote.debug.");
    Integer port = resolver.getProperty("local-port", Integer.class);
    if (port == null) {
        port = RemoteDevToolsProperties.Debug.DEFAULT_LOCAL_PORT;
    }
    if (isPortAvailable(port)) {
        return ConditionOutcome.match(message.foundExactly("local debug port"));
    }
    return ConditionOutcome.noMatch(message.didNotFind("local debug port").atAll());
}
Also used : ConditionMessage(org.springframework.boot.autoconfigure.condition.ConditionMessage) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Example 5 with RelaxedPropertyResolver

use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.

the class SpringBootContextLoader method hasCustomServerPort.

private boolean hasCustomServerPort(List<String> properties) {
    PropertySources sources = convertToPropertySources(properties);
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(new PropertySourcesPropertyResolver(sources), "server.");
    return resolver.containsProperty("port");
}
Also used : PropertySourcesPropertyResolver(org.springframework.core.env.PropertySourcesPropertyResolver) PropertySources(org.springframework.core.env.PropertySources) MutablePropertySources(org.springframework.core.env.MutablePropertySources) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Aggregations

RelaxedPropertyResolver (org.springframework.boot.bind.RelaxedPropertyResolver)24 ConditionMessage (org.springframework.boot.autoconfigure.condition.ConditionMessage)5 PropertyResolver (org.springframework.core.env.PropertyResolver)5 ConditionOutcome (org.springframework.boot.autoconfigure.condition.ConditionOutcome)3 Map (java.util.Map)2 MutablePropertySources (org.springframework.core.env.MutablePropertySources)2 PropertySources (org.springframework.core.env.PropertySources)2 PropertySourcesPropertyResolver (org.springframework.core.env.PropertySourcesPropertyResolver)2 AbstractCacheBuilder (com.alicp.jetcache.AbstractCacheBuilder)1 CacheBuilder (com.alicp.jetcache.CacheBuilder)1 ConfigProvider (com.alicp.jetcache.anno.support.ConfigProvider)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 BeansException (org.springframework.beans.BeansException)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1