001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure.freemarker; 018 019import java.util.HashMap; 020import java.util.Map; 021 022import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties; 023import org.springframework.boot.context.properties.ConfigurationProperties; 024 025/** 026 * {@link ConfigurationProperties} for configuring FreeMarker. 027 * 028 * @author Dave Syer 029 * @author Andy Wilkinson 030 * @since 1.1.0 031 */ 032@ConfigurationProperties(prefix = "spring.freemarker") 033public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties { 034 035 public static final String DEFAULT_TEMPLATE_LOADER_PATH = "classpath:/templates/"; 036 037 public static final String DEFAULT_PREFIX = ""; 038 039 public static final String DEFAULT_SUFFIX = ".ftl"; 040 041 /** 042 * Well-known FreeMarker keys which are passed to FreeMarker's Configuration. 043 */ 044 private Map<String, String> settings = new HashMap<>(); 045 046 /** 047 * Comma-separated list of template paths. 048 */ 049 private String[] templateLoaderPath = new String[] { DEFAULT_TEMPLATE_LOADER_PATH }; 050 051 /** 052 * Whether to prefer file system access for template loading. File system access 053 * enables hot detection of template changes. 054 */ 055 private boolean preferFileSystemAccess = true; 056 057 public FreeMarkerProperties() { 058 super(DEFAULT_PREFIX, DEFAULT_SUFFIX); 059 } 060 061 public Map<String, String> getSettings() { 062 return this.settings; 063 } 064 065 public void setSettings(Map<String, String> settings) { 066 this.settings = settings; 067 } 068 069 public String[] getTemplateLoaderPath() { 070 return this.templateLoaderPath; 071 } 072 073 public boolean isPreferFileSystemAccess() { 074 return this.preferFileSystemAccess; 075 } 076 077 public void setPreferFileSystemAccess(boolean preferFileSystemAccess) { 078 this.preferFileSystemAccess = preferFileSystemAccess; 079 } 080 081 public void setTemplateLoaderPath(String... templateLoaderPaths) { 082 this.templateLoaderPath = templateLoaderPaths; 083 } 084 085}