Factory that configures a FreeMarker Configuration. Can be used standalone, but
typically you will either use FreeMarkerConfigurationFactoryBean for preparing a
Configuration as bean reference, or FreeMarkerConfigurer for web views.

The optional "configLocation" property sets the location of a FreeMarker
properties file, within the current application. FreeMarker properties can be
overridden via "freemarkerSettings". All of these properties will be set by
calling FreeMarker's Configuration.setSettings() method and are
subject to constraints set by FreeMarker.

The "freemarkerVariables" property can be used to specify a Map of
shared variables that will be applied to the Configuration via the
setAllSharedVariables() method. Like setSettings(),
these entries are subject to FreeMarker constraints.

The simplest way to use this class is to specify a "templateLoaderPath";
FreeMarker does not need any further configuration then.

postProcessConfiguration(freemarker.template.Configuration config)
To be overridden by subclasses that want to to perform custom
post-processing of the Configuration object after this factory
performed its default initialization.

protected void

postProcessTemplateLoaders(java.util.List<freemarker.cache.TemplateLoader> templateLoaders)
To be overridden by subclasses that want to to register custom
TemplateLoader instances after this factory created its default
template loaders.

setDefaultEncoding(java.lang.String defaultEncoding)
Set the default encoding for the FreeMarker configuration.

void

setFreemarkerSettings(java.util.Properties settings)
Set properties that contain well-known FreeMarker keys which will be
passed to FreeMarker's Configuration.setSettings method.

void

setFreemarkerVariables(java.util.Map<java.lang.String,java.lang.Object> variables)
Set a Map that contains well-known FreeMarker objects which will be passed
to FreeMarker's Configuration.setAllSharedVariables() method.

void

setPostTemplateLoaders(freemarker.cache.TemplateLoader[] postTemplateLoaders)
Set a List of TemplateLoaders that will be used to search
for templates.

setPreTemplateLoaders

Set a List of TemplateLoaders that will be used to search
for templates. For example, one or more custom loaders such as database
loaders could be configured and injected here.

The TemplateLoaders specified here will be
registered before the default template loaders that this factory
registers (such as loaders for specified "templateLoaderPaths" or any
loaders registered in postProcessTemplateLoaders(java.util.List)).

setPostTemplateLoaders

Set a List of TemplateLoaders that will be used to search
for templates. For example, one or more custom loaders such as database
loaders can be configured.

The TemplateLoaders specified here will be
registered after the default template loaders that this factory
registers (such as loaders for specified "templateLoaderPaths" or any
loaders registered in postProcessTemplateLoaders(java.util.List)).

setTemplateLoaderPaths

When populated via a String, standard URLs like "file:" and "classpath:"
pseudo URLs are supported, as understood by ResourceEditor. Allows for
relative paths when running in an ApplicationContext.

Will define a path for the default FreeMarker template loader.
If a specified resource cannot be resolved to a java.io.File,
a generic SpringTemplateLoader will be used, without modification detection.

To enforce the use of SpringTemplateLoader, i.e. to not resolve a path
as file system resource in any case, turn off the "preferFileSystemAccess"
flag. See the latter's javadoc for details.

If you wish to specify your own list of TemplateLoaders, do not set this
property and instead use setTemplateLoaders(List templateLoaders)

getResourceLoader

Return the Spring ResourceLoader to use for loading FreeMarker template files.

setPreferFileSystemAccess

public void setPreferFileSystemAccess(boolean preferFileSystemAccess)

Set whether to prefer file system access for template loading.
File system access enables hot detection of template changes.

If this is enabled, FreeMarkerConfigurationFactory will try to resolve
the specified "templateLoaderPath" as file system resource (which will work
for expanded class path resources and ServletContext resources too).

Default is "true". Turn this off to always load via SpringTemplateLoader
(i.e. as stream, without hot detection of template changes), which might
be necessary if some of your templates reside in an expanded classes
directory while others reside in jar files.

postProcessTemplateLoaders

To be overridden by subclasses that want to to register custom
TemplateLoader instances after this factory created its default
template loaders.

Called by createConfiguration(). Note that specified
"postTemplateLoaders" will be registered after any loaders
registered by this callback; as a consequence, they are are not
included in the given List.

Parameters:

templateLoaders - the current List of TemplateLoader instances,
to be modified by a subclass