Polish templates code
This commit is contained in:
parent
1d5cddc1e9
commit
decee8d871
|
@ -46,6 +46,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
|||
* {@link EnableAutoConfiguration Auto-configuration} for FreeMarker.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(freemarker.template.Configuration.class)
|
||||
|
|
|
@ -22,11 +22,11 @@ import org.springframework.core.io.ResourceLoader;
|
|||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link TemplateAvailabilityProvider} that provides availability information
|
||||
* for FreeMarker view templates
|
||||
* {@link TemplateAvailabilityProvider} that provides availability information for
|
||||
* FreeMarker view templates
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class FreeMarkerTemplateAvailabilityProvider implements
|
||||
TemplateAvailabilityProvider {
|
||||
|
@ -34,15 +34,16 @@ public class FreeMarkerTemplateAvailabilityProvider implements
|
|||
@Override
|
||||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("freemarker.template.Configuration",
|
||||
classLoader)) {
|
||||
String loaderPath = environment.getProperty("spring.freemarker.templateLoaderPath",
|
||||
if (ClassUtils.isPresent("freemarker.template.Configuration", classLoader)) {
|
||||
String loaderPath = environment.getProperty(
|
||||
"spring.freemarker.templateLoaderPath",
|
||||
FreeMarkerAutoConfiguration.DEFAULT_TEMPLATE_LOADER_PATH);
|
||||
String prefix = environment.getProperty("spring.freemarker.prefix",
|
||||
FreeMarkerAutoConfiguration.DEFAULT_PREFIX);
|
||||
String suffix = environment.getProperty("spring.freemarker.suffix",
|
||||
FreeMarkerAutoConfiguration.DEFAULT_SUFFIX);
|
||||
return resourceLoader.getResource(loaderPath + prefix + view + suffix).exists();
|
||||
return resourceLoader.getResource(loaderPath + prefix + view + suffix)
|
||||
.exists();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.springframework.util.ClassUtils;
|
|||
* Thymeleaf view templates
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class ThymeleafTemplateAvailabilityProvider implements
|
||||
TemplateAvailabilityProvider {
|
||||
|
|
|
@ -21,6 +21,13 @@ import org.springframework.core.env.Environment;
|
|||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link TemplateAvailabilityProvider} that provides availability information for JSP
|
||||
* view templates
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProvider {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ public class SampleController {
|
|||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
|
@ -74,5 +74,4 @@ public class SampleController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,9 +28,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
* The GemstoneAppConfiguration class for allowing Spring Boot to pickup additional
|
||||
* application Spring configuration meta-data for GemFire, which must be specified in
|
||||
* Spring Data GemFire's XML namespace.
|
||||
* <p/>
|
||||
*
|
||||
* @author John Blum
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ImportResource("/spring-data-gemfire-cache.xml")
|
||||
|
|
|
@ -20,17 +20,20 @@ import org.springframework.core.env.Environment;
|
|||
import org.springframework.core.io.ResourceLoader;
|
||||
|
||||
/**
|
||||
* A {@code TemplateAvailabilityProvider} indicates the availability of view templates for
|
||||
* a particular templating engine such as FreeMarker or Thymeleaf
|
||||
* Indicates the availability of view templates for a particular templating engine such as
|
||||
* FreeMarker or Thymeleaf
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface TemplateAvailabilityProvider {
|
||||
|
||||
/**
|
||||
* Returns {@code true} if a template is available for the given {@code view},
|
||||
* otherwise {@code false} is returned.
|
||||
* Returns {@code true} if a template is available for the given {@code view}.
|
||||
* @param view the view name
|
||||
* @param environment the environment
|
||||
* @param classLoader the class loader
|
||||
* @param resourceLoader the resource loader
|
||||
*/
|
||||
boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader);
|
||||
|
|
Loading…
Reference in New Issue