Search in sources :

Example 21 with RelaxedPropertyResolver

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

the class OnEnabledEndpointElementCondition method getDefaultEndpointsOutcome.

protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), this.prefix + "defaults.");
    boolean match = Boolean.valueOf(resolver.getProperty("enabled", "true"));
    return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType).because(this.prefix + "defaults.enabled is considered " + match));
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) ConditionOutcome(org.springframework.boot.autoconfigure.condition.ConditionOutcome)

Example 22 with RelaxedPropertyResolver

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

the class MustacheEnvironmentCollector method setEnvironment.

@Override
public void setEnvironment(Environment environment) {
    this.environment = (ConfigurableEnvironment) environment;
    this.target = new HashMap<>();
    new RelaxedDataBinder(this.target).bind(new PropertySourcesPropertyValues(this.environment.getPropertySources()));
    this.propertyResolver = new RelaxedPropertyResolver(environment);
}
Also used : RelaxedDataBinder(org.springframework.boot.bind.RelaxedDataBinder) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) PropertySourcesPropertyValues(org.springframework.boot.bind.PropertySourcesPropertyValues)

Example 23 with RelaxedPropertyResolver

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

the class ImageBanner method printBanner.

private void printBanner(Environment environment, PrintStream out) throws IOException {
    PropertyResolver properties = new RelaxedPropertyResolver(environment, "banner.image.");
    int width = properties.getProperty("width", Integer.class, 76);
    int height = properties.getProperty("height", Integer.class, 0);
    int margin = properties.getProperty("margin", Integer.class, 2);
    boolean invert = properties.getProperty("invert", Boolean.class, false);
    BufferedImage image = readImage(width, height);
    printBanner(image, margin, invert, out);
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) PropertyResolver(org.springframework.core.env.PropertyResolver) BufferedImage(java.awt.image.BufferedImage)

Example 24 with RelaxedPropertyResolver

use of org.springframework.boot.bind.RelaxedPropertyResolver in project jetcache by alibaba.

the class AbstractCacheAutoInit method process.

private void process(String prefix, Map cacheBuilders, boolean local) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(applicationContext.getEnvironment(), prefix);
    Map<String, Object> m = resolver.getSubProperties("");
    Set<String> cacheAreaNames = m.keySet().stream().map((s) -> s.substring(0, s.indexOf('.'))).collect(Collectors.toSet());
    for (String cacheArea : cacheAreaNames) {
        if (!typeName.equals(m.get(cacheArea + ".type"))) {
            continue;
        }
        RelaxedPropertyResolver r = new RelaxedPropertyResolver(applicationContext.getEnvironment(), prefix + cacheArea + ".");
        logger.info("init cache area {} , type= {}", cacheArea, typeName);
        CacheBuilder c = initCache(r, local ? "local." + cacheArea : "remote." + cacheArea);
        cacheBuilders.put(cacheArea, c);
    }
}
Also used : Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) BeansException(org.springframework.beans.BeansException) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) ConfigProvider(com.alicp.jetcache.anno.support.ConfigProvider) Map(java.util.Map) AbstractCacheBuilder(com.alicp.jetcache.AbstractCacheBuilder) PostConstruct(javax.annotation.PostConstruct) CacheBuilder(com.alicp.jetcache.CacheBuilder) ApplicationContextAware(org.springframework.context.ApplicationContextAware) AbstractCacheBuilder(com.alicp.jetcache.AbstractCacheBuilder) CacheBuilder(com.alicp.jetcache.CacheBuilder) 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