Search in sources :

Example 16 with RelaxedPropertyResolver

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

the class GroovyTemplateAvailabilityProvider method isTemplateAvailable.

@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("groovy.text.TemplateEngine", classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.groovy.template.");
        String loaderPath = resolver.getProperty("resource-loader-path", GroovyTemplateProperties.DEFAULT_RESOURCE_LOADER_PATH);
        String prefix = resolver.getProperty("prefix", GroovyTemplateProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix", GroovyTemplateProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(loaderPath + prefix + view + suffix).exists();
    }
    return false;
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) PropertyResolver(org.springframework.core.env.PropertyResolver)

Example 17 with RelaxedPropertyResolver

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

the class SpringApplication method configureIgnoreBeanInfo.

private void configureIgnoreBeanInfo(ConfigurableEnvironment environment) {
    if (System.getProperty(CachedIntrospectionResults.IGNORE_BEANINFO_PROPERTY_NAME) == null) {
        RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.beaninfo.");
        Boolean ignore = resolver.getProperty("ignore", Boolean.class, Boolean.TRUE);
        System.setProperty(CachedIntrospectionResults.IGNORE_BEANINFO_PROPERTY_NAME, ignore.toString());
    }
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Example 18 with RelaxedPropertyResolver

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

the class FileEncodingApplicationListener method onApplicationEvent.

@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(event.getEnvironment(), "spring.");
    if (resolver.containsProperty("mandatoryFileEncoding")) {
        String encoding = System.getProperty("file.encoding");
        String desired = resolver.getProperty("mandatoryFileEncoding");
        if (encoding != null && !desired.equalsIgnoreCase(encoding)) {
            logger.error("System property 'file.encoding' is currently '" + encoding + "'. It should be '" + desired + "' (as defined in 'spring.mandatoryFileEncoding').");
            logger.error("Environment variable LANG is '" + System.getenv("LANG") + "'. You could use a locale setting that matches encoding='" + desired + "'.");
            logger.error("Environment variable LC_ALL is '" + System.getenv("LC_ALL") + "'. You could use a locale setting that matches encoding='" + desired + "'.");
            throw new IllegalStateException("The Java Virtual Machine has not been configured to use the " + "desired default character encoding (" + desired + ").");
        }
    }
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Example 19 with RelaxedPropertyResolver

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

the class AnsiOutputApplicationListener method onApplicationEvent.

@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(event.getEnvironment(), "spring.output.ansi.");
    if (resolver.containsProperty("enabled")) {
        String enabled = resolver.getProperty("enabled");
        AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
    }
    if (resolver.containsProperty("console-available")) {
        AnsiOutput.setConsoleAvailable(resolver.getProperty("console-available", Boolean.class));
    }
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) Enabled(org.springframework.boot.ansi.AnsiOutput.Enabled)

Example 20 with RelaxedPropertyResolver

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

the class FreeMarkerTemplateAvailabilityProvider method isTemplateAvailable.

@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("freemarker.template.Configuration", classLoader)) {
        RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.freemarker.");
        String loaderPath = resolver.getProperty("template-loader-path", FreeMarkerProperties.DEFAULT_TEMPLATE_LOADER_PATH);
        String prefix = resolver.getProperty("prefix", FreeMarkerProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix", FreeMarkerProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(loaderPath + prefix + view + suffix).exists();
    }
    return false;
}
Also used : 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