Class FreemarkerMailGenerator

  • All Implemented Interfaces:
    MailGenerator

    @Service("mailGenerator#freemarker")
    public class FreemarkerMailGenerator
    extends Object
    implements MailGenerator
    Mail generator that uses freemarker templates. This implementation sets the following model values that can be used in templates:
    • applicationUrl
    • urlPath
    • authKey
    • accountId
    • requestedOn
    • expiresOn
    The additional template data is added for interpolation, if not null. This implementation is location enabled. That means, it will try to find templates in the following order:
    • templateName_language_country.ftl
    • templateName_language.ftl
    • templateName.ftl
    The default encoding used for reading the template is UTF-8
    Author:
    Martin Stockhammer
    • Method Detail

      • generateMail

        public String generateMail​(String templateName,
                                   Locale locale,
                                   AuthenticationKey authkey,
                                   String baseUrl,
                                   Map<String,​Object> templateData)
        Description copied from interface: MailGenerator
        Generates a mail string from a template. The given locale is used for retrieving the template. How the template will be located depends on the underlying implementation. The templateData is used as model data that is interpolated from the template.
        Specified by:
        generateMail in interface MailGenerator
        Parameters:
        templateName - the template name without extension
        locale - the locale used to find the template file
        authkey - the authentication key
        baseUrl - the base url
        templateData - additional template data, may be null
        Returns:
        the string generated from the template
      • generateMail

        public String generateMail​(String templateName,
                                   AuthenticationKey authenticationKey,
                                   String baseUrl)
        Description copied from interface: MailGenerator
        Generates a mail string from a template. How the template will be located depends on the underlying implementation. It uses a default locale.
        Specified by:
        generateMail in interface MailGenerator
        Parameters:
        templateName - the template name without extension
        authenticationKey - the authentication key of the current user
        baseUrl - the base url
        Returns:
        A string for the mail body generated from the template
      • generateMail

        public String generateMail​(String templateName,
                                   Locale locale,
                                   AuthenticationKey authenticationKey,
                                   String baseUrl)
        Description copied from interface: MailGenerator
        Generates a mail string from a template. The given locale is used for retrieving the template. How the template will be located depends on the underlying implementation.
        Specified by:
        generateMail in interface MailGenerator
        Parameters:
        templateName - the template name without extension
        locale - the locale used to find the template file
        authenticationKey - the authentication key of the current user
        baseUrl - the base url
        Returns:
        a string for the mail body generated from the template
      • setFreemarkerConfiguration

        public void setFreemarkerConfiguration​(freemarker.template.Configuration freemarkerConfiguration)