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:
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.
Loader "com.hardis.adelia.mergedocengine.freemarker.conf.FileTemplateLoader"
For example, if your user templates are in the "c:\billingTemplates" and "c:\reportingTemplates" directories:
Loader "com.hardis.adelia.mergedocengine.freemarker.conf.ClassTemplateLoader"
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):
|
Name |
Type |
Description |
Mandatory |
schemeFileURI |
String |
Absolute or relative path of the ZIP file containing the templates. |
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 of templates read from a locale with no associated encoding.
Default value: UTF-8
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.
Defines the locale used by default if no locale is specified in the Web services parameters.
Defines the error handling strategy during template processing.
Default value: "rethrow"
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)
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.