Products Downloads


French version


 

Apache FreeMarker is configured using the freemarker.properties file.

This configuration is mandatory in order to make FreeMarker work with your own templates.


The first step entails retrieving a copy of this file. See MergeTransformMicroService page for more details.

This file is a Java .properties file (key syntax = value).


The second step entails changing or entering the keys according to requirements.

The only key that must be changed is the "template_loader" key, which is used to define the template loader.


Key

Description

template_loader


Template loader.

Default value:

freemarker.cache.MultiTemplateLoader( \

[com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/com/hardis/adelia/mergedocengine/freemarker/lib")])


The "\" character indicates a line break in a key's value.


You need to add your own loader to the APE's default loader.

There are several types of loader available, depending on the format of your template deliverables, i.e.

    • com.hardis.adelia.mergedocengine.freemarker.conf.FileTemplateLoader: Your templates and resource files (image files, character font files, etc.) are in a file system directory;
    • com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader: Your templates and resource files (Java class files, image files, character font files, etc.) are in a JAR file which is accessible from the Java CLASSPATH;
    • com.hardis.adelia.mergedocengine.freemarker.conf.ZipFileTemplateLoader: Your templates and resource files (image files, character font files, etc.) are in a ZIP file.


Loader "com.hardis.adelia.mergedocengine.freemarker.conf.FileTemplateLoader"

Name

Type

Description

Mandatory

baseDir

String

Absolute or relative path of the directory containing the templates.
If the path is relative, it is relative to the APE run directory.

Y

disableCanonicalPathCheck

Boolean

Disables security checks on the search path deduced from the template, which prevents the loader from searching for templates outside the baseDir directory.

If you want symbolic links that point outside the template directory to work, you need to disable this feature.

N (default value: False)

For example, if your user templates are in the "c:\billingTemplates" and "c:\reportingTemplates" directories:

template_loader=freemarker.cache.MultiTemplateLoader( \ 

[com.hardis.adelia.mergedocengine.freemarker.conf.FileTemplateLoader(java.io.File ("c:/billingTemplates")), \ 

com.hardis.adelia.mergedocengine.freemarker.conf.FileTemplateLoader(java.io.File ("c:/reportingTemplates"), true), \ 

com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/com/hardis/adelia/mergedocengine/freemarker/lib")])


Loader "com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader"

Name

Type

Description

Mandatory

resourceLoaderClass

Java.lang.Class

Java class for defining the class loader used to search for a template.

Y (initial value: com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION)

basePackagePath

String

Path (absolute or relative) of the Java package used as a basis for searching for a template.
If the path is relative (not starting with "/"), it is relative to the resourceLoaderClass package path.

Y

For example, if your user templates are in a JAR file located in the "/myTemplates" package (the JAR file must be present in the Java CLASSPATH):

template_loader=freemarker.cache.MultiTemplateLoader( \

[com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/myTemplates"), \ 

com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/com/hardis/adelia/mergedocengine/freemarker/lib")])


Loader
 "com.hardis.adelia.mergedocengine.freemarker.conf.ZipFileTemplateLoader"

Name

Type

Description

Mandatory

schemeFileURI

String

Absolute or relative path of the ZIP file containing the templates.
If the path is relative, it is relative to the APE run directory.

Y

basePackagePath

String

Sub-directory in the ZIP file from which a template can be searched for.

N (default value: " ")
useCache Boolean Uses a memory cache to access the content of the ZIP file. N (default value: "True")

For example, if your user templates are in the "c:\billingTemplates.zip" (accessible from the file root) and "c:\reportingTemplates.zip" (accessible from the "year2019" sub-directory) files:

template_loader=freemarker.cache.MultiTemplateLoader( \

[com.hardis.adelia.mergedocengine.freemarker.conf.ZipFileTemplateLoader("jar:file:///c:/billingTemplates.zip"), \ 

com.hardis.adelia.mergedocengine.freemarker.conf.ZipFileTemplateLoader("jar:file:///c:/reportingTemplates.zip""year2019"), \ 

com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader(com.hardis.adelia.mergedocengine.ProcessTemplate.CLASS_FOR_OBJECT_BUILDER_EXPRESSION, "/com/hardis/adelia/mergedocengine/freemarker/lib")]


default_encoding


Default encoding of templates read from a locale with no associated encoding.

Default value: UTF-8


template_update_delay


Defines the time in milliseconds that needs to elapse before the template cache management module checks whether there is a more recent version of a template than the one in the cache. The default value is 5 s.


In the template development phase, this value indicates the minimum wait time between when the template is saved (saving a change for example) and its availability to be processed (to test the result of the change) by the FreeMarker engine. So a value in the region of one second needs to be indicated.


In the production phase, it may be beneficial to have a very large value to avoid affecting the engine's performance under heavy load.


locale


Defines the locale used by default if no locale is specified in the Web services parameters.


template_exception_handler


Defines the error handling strategy during template processing.

Default value: "rethrow"


boolean_format


Defines the alphanumeric values used to convert a FreeMarker boolean value into an alphanumeric string in the ${ booleanValue } interpolation.

Default values: yes, no ("yes" for true and "no" for false)


extSharedVariables


Used to define one or more variables which are shared by all the templates.

The syntax must be a Map. For example: extSharedVariables = { "sharedNumberVar": 10, \

"sharedBoolVar": true, "sharedStringVar": "string value", \

"sharedDateVar": java.sql.Date(1531750144138), \

"sharedTimeVar": java.sql.Time(1531750144138), \

"sharedDateTimeVar": java.sql. Timesatmp(1531750144138), \

"sharedSequenceVar": [1, 2, 3], \

"sharedHashVar": { "subVar1": 1, "subVar2": false } \

}


These variables may be manipulated in the templates by using ${ sharedNumberVar }, ${sharedSequenceVar[1]} , ${sharedHashVar.subVar1} interpolations, etc.


Important: if a level-one variable in the data model has the same name as a shared variable, the data model variable will "hide" the shared variable.



↑ Top of page

  • Aucune étiquette