Commit d948ec58 authored by cohee016's avatar cohee016 Committed by Phillip Webb

Add Freemarker `prefer-file-system-access` support

Add a `spring.freemarker.prefer-file-system-access` property and update
FreeMarkerAutoConfiguration to support it.

Fixes gh-2901
parent 61fc4f3f
/*
* 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.
......@@ -91,6 +91,7 @@ public class FreeMarkerAutoConfiguration {
protected void applyProperties(FreeMarkerConfigurationFactory factory) {
factory.setTemplateLoaderPaths(this.properties.getTemplateLoaderPath());
factory.setPreferFileSystemAccess(this.properties.isPreferFileSystemAccess());
factory.setDefaultEncoding(this.properties.getCharset());
Properties settings = new Properties();
settings.putAll(this.properties.getSettings());
......
/*
* 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.
......@@ -48,6 +48,12 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
*/
private String[] templateLoaderPath = new String[] { DEFAULT_TEMPLATE_LOADER_PATH };
/**
* Prefer file system access for template loading. File system access enables hot
* detection of template changes.
*/
private boolean preferFileSystemAccess = true;
public FreeMarkerProperties() {
super(DEFAULT_PREFIX, DEFAULT_SUFFIX);
}
......@@ -64,6 +70,14 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
return this.templateLoaderPath;
}
public boolean isPreferFileSystemAccess() {
return this.preferFileSystemAccess;
}
public void setPreferFileSystemAccess(boolean preferFileSystemAccess) {
this.preferFileSystemAccess = preferFileSystemAccess;
}
public void setTemplateLoaderPath(String... templateLoaderPaths) {
this.templateLoaderPath = templateLoaderPaths;
}
......
......@@ -197,6 +197,7 @@ content into your application; rather pick only the properties that you need.
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
spring.freemarker.prefix=
spring.freemarker.prefer-file-system-access=true # prefer file system access for template loading
spring.freemarker.request-context-attribute=
spring.freemarker.settings.*=
spring.freemarker.suffix=.ftl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment