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;
}
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());
}
}
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 + ").");
}
}
}
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));
}
}
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;
}
Aggregations