use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class SessionCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage.forCondition("Session Condition");
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "spring.session.");
StoreType sessionStoreType = SessionStoreMappings.getType(((AnnotationMetadata) metadata).getClassName());
if (!resolver.containsProperty("store-type")) {
return ConditionOutcome.noMatch(message.didNotFind("spring.session.store-type property").atAll());
}
String value = resolver.getProperty("store-type").replace('-', '_').toUpperCase();
if (value.equals(sessionStoreType.name())) {
return ConditionOutcome.match(message.found("spring.session.store-type property").items(sessionStoreType));
}
return ConditionOutcome.noMatch(message.found("spring.session.store-type property").items(value));
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class TemplateAvailabilityProviders method getProvider.
/**
* Get the provider that can be used to render the given view.
* @param view the view to render
* @param environment the environment
* @param classLoader the class loader
* @param resourceLoader the resource loader
* @return a {@link TemplateAvailabilityProvider} or null
*/
public TemplateAvailabilityProvider getProvider(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) {
Assert.notNull(view, "View must not be null");
Assert.notNull(environment, "Environment must not be null");
Assert.notNull(classLoader, "ClassLoader must not be null");
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(environment, "spring.template.provider.");
if (!propertyResolver.getProperty("cache", Boolean.class, true)) {
return findProvider(view, environment, classLoader, resourceLoader);
}
TemplateAvailabilityProvider provider = this.resolved.get(view);
if (provider == null) {
synchronized (this.cache) {
provider = findProvider(view, environment, classLoader, resourceLoader);
provider = (provider == null ? NONE : provider);
this.resolved.put(view, provider);
this.cache.put(view, provider);
}
}
return (provider == NONE ? null : provider);
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class ThymeleafTemplateAvailabilityProvider method isTemplateAvailable.
@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("org.thymeleaf.spring5.SpringTemplateEngine", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.thymeleaf.");
String prefix = resolver.getProperty("prefix", ThymeleafProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix", ThymeleafProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(prefix + view + suffix).exists();
}
return false;
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class MustacheTemplateAvailabilityProvider method isTemplateAvailable.
@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("com.samskivert.mustache.Template", classLoader)) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.mustache.");
String prefix = resolver.getProperty("prefix", MustacheProperties.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix", MustacheProperties.DEFAULT_SUFFIX);
return resourceLoader.getResource(prefix + view + suffix).exists();
}
return false;
}
use of org.springframework.boot.bind.RelaxedPropertyResolver in project spring-boot by spring-projects.
the class JspTemplateAvailabilityProvider method getResourceName.
private String getResourceName(String view, Environment environment) {
PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.mvc.view.");
String prefix = resolver.getProperty("prefix", WebMvcAutoConfiguration.DEFAULT_PREFIX);
String suffix = resolver.getProperty("suffix", WebMvcAutoConfiguration.DEFAULT_SUFFIX);
return prefix + view + suffix;
}
Aggregations