Merge branch '1.2.x'
This commit is contained in:
commit
d1b936ef2c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.freemarker;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
|
@ -35,11 +36,13 @@ public class FreeMarkerTemplateAvailabilityProvider implements
|
|||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("freemarker.template.Configuration", classLoader)) {
|
||||
String loaderPath = environment.getProperty("spring.freemarker.path",
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.freemarker.");
|
||||
String loaderPath = resolver.getProperty("template-loader-path",
|
||||
FreeMarkerProperties.DEFAULT_TEMPLATE_LOADER_PATH);
|
||||
String prefix = environment.getProperty("spring.freemarker.prefix",
|
||||
String prefix = resolver.getProperty("prefix",
|
||||
FreeMarkerProperties.DEFAULT_PREFIX);
|
||||
String suffix = environment.getProperty("spring.freemarker.suffix",
|
||||
String suffix = resolver.getProperty("suffix",
|
||||
FreeMarkerProperties.DEFAULT_SUFFIX);
|
||||
return resourceLoader.getResource(loaderPath + prefix + view + suffix)
|
||||
.exists();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
package org.springframework.boot.autoconfigure.groovy.template;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.PropertyResolver;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
@ -34,9 +36,11 @@ public class GroovyTemplateAvailabilityProvider implements TemplateAvailabilityP
|
|||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("groovy.text.TemplateEngine", classLoader)) {
|
||||
String prefix = environment.getProperty("spring.groovy.template.prefix",
|
||||
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.groovy.template.");
|
||||
String prefix = resolver.getProperty("prefix",
|
||||
GroovyTemplateProperties.DEFAULT_PREFIX);
|
||||
String suffix = environment.getProperty("spring.groovy.template.suffix",
|
||||
String suffix = resolver.getProperty("suffix",
|
||||
GroovyTemplateProperties.DEFAULT_SUFFIX);
|
||||
return resourceLoader.getResource(prefix + view + suffix).exists();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
package org.springframework.boot.autoconfigure.mustache;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.PropertyResolver;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
@ -34,9 +36,11 @@ public class MustacheTemplateAvailabilityProvider implements TemplateAvailabilit
|
|||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("com.samskivert.mustache.Template", classLoader)) {
|
||||
String prefix = environment.getProperty("spring.mustache.prefix",
|
||||
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.mustache.");
|
||||
String prefix = resolver.getProperty("prefix",
|
||||
MustacheProperties.DEFAULT_PREFIX);
|
||||
String suffix = environment.getProperty("spring.mustache.suffix",
|
||||
String suffix = resolver.getProperty("suffix",
|
||||
MustacheProperties.DEFAULT_SUFFIX);
|
||||
return resourceLoader.getResource(prefix + view + suffix).exists();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
package org.springframework.boot.autoconfigure.thymeleaf;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.PropertyResolver;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
@ -36,9 +38,11 @@ public class ThymeleafTemplateAvailabilityProvider implements
|
|||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("org.thymeleaf.spring4.SpringTemplateEngine",
|
||||
classLoader)) {
|
||||
String prefix = environment.getProperty("spring.thymeleaf.prefix",
|
||||
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.thymeleaf.");
|
||||
String prefix = resolver.getProperty("prefix",
|
||||
ThymeleafProperties.DEFAULT_PREFIX);
|
||||
String suffix = environment.getProperty("spring.thymeleaf.suffix",
|
||||
String suffix = resolver.getProperty("suffix",
|
||||
ThymeleafProperties.DEFAULT_SUFFIX);
|
||||
return resourceLoader.getResource(prefix + view + suffix).exists();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
package org.springframework.boot.autoconfigure.velocity;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.PropertyResolver;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
@ -34,12 +36,13 @@ public class VelocityTemplateAvailabilityProvider implements TemplateAvailabilit
|
|||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
|
||||
String loaderPath = environment.getProperty(
|
||||
"spring.velocity.resourceLoaderPath",
|
||||
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.velocity.");
|
||||
String loaderPath = resolver.getProperty("resource-loader-path",
|
||||
VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
|
||||
String prefix = environment.getProperty("spring.velocity.prefix",
|
||||
String prefix = resolver.getProperty("prefix",
|
||||
VelocityProperties.DEFAULT_PREFIX);
|
||||
String suffix = environment.getProperty("spring.velocity.suffix",
|
||||
String suffix = resolver.getProperty("suffix",
|
||||
VelocityProperties.DEFAULT_SUFFIX);
|
||||
return resourceLoader.getResource(loaderPath + prefix + view + suffix)
|
||||
.exists();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -52,9 +52,8 @@ public class FreeMarkerTemplateAvailabilityProviderTests {
|
|||
|
||||
@Test
|
||||
public void availabilityOfTemplateWithCustomLoaderPath() {
|
||||
this.environment.setProperty("spring.freemarker.path",
|
||||
this.environment.setProperty("spring.freemarker.template-loader-path",
|
||||
"classpath:/custom-templates/");
|
||||
|
||||
assertTrue(this.provider.isTemplateAvailable("custom", this.environment,
|
||||
getClass().getClassLoader(), this.resourceLoader));
|
||||
}
|
||||
|
|
@ -62,7 +61,6 @@ public class FreeMarkerTemplateAvailabilityProviderTests {
|
|||
@Test
|
||||
public void availabilityOfTemplateWithCustomPrefix() {
|
||||
this.environment.setProperty("spring.freemarker.prefix", "prefix/");
|
||||
|
||||
assertTrue(this.provider.isTemplateAvailable("prefixed", this.environment,
|
||||
getClass().getClassLoader(), this.resourceLoader));
|
||||
}
|
||||
|
|
@ -70,7 +68,6 @@ public class FreeMarkerTemplateAvailabilityProviderTests {
|
|||
@Test
|
||||
public void availabilityOfTemplateWithCustomSuffix() {
|
||||
this.environment.setProperty("spring.freemarker.suffix", ".freemarker");
|
||||
|
||||
assertTrue(this.provider.isTemplateAvailable("suffixed", this.environment,
|
||||
getClass().getClassLoader(), this.resourceLoader));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -54,7 +54,6 @@ public class VelocityTemplateAvailabilityProviderTests {
|
|||
public void availabilityOfTemplateWithCustomLoaderPath() {
|
||||
this.environment.setProperty("spring.velocity.resourceLoaderPath",
|
||||
"classpath:/custom-templates/");
|
||||
|
||||
assertTrue(this.provider.isTemplateAvailable("custom", this.environment,
|
||||
getClass().getClassLoader(), this.resourceLoader));
|
||||
}
|
||||
|
|
@ -62,7 +61,6 @@ public class VelocityTemplateAvailabilityProviderTests {
|
|||
@Test
|
||||
public void availabilityOfTemplateWithCustomPrefix() {
|
||||
this.environment.setProperty("spring.velocity.prefix", "prefix/");
|
||||
|
||||
assertTrue(this.provider.isTemplateAvailable("prefixed", this.environment,
|
||||
getClass().getClassLoader(), this.resourceLoader));
|
||||
}
|
||||
|
|
@ -70,7 +68,6 @@ public class VelocityTemplateAvailabilityProviderTests {
|
|||
@Test
|
||||
public void availabilityOfTemplateWithCustomSuffix() {
|
||||
this.environment.setProperty("spring.velocity.suffix", ".freemarker");
|
||||
|
||||
assertTrue(this.provider.isTemplateAvailable("suffixed", this.environment,
|
||||
getClass().getClassLoader(), this.resourceLoader));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue