Class ClasspathResourceMessageTemplateDataSource

java.lang.Object
net.solarnetwork.central.mail.support.SimpleMessageDataSource
net.solarnetwork.central.mail.support.ClasspathResourceMessageTemplateDataSource
All Implemented Interfaces:
MessageDataSource, MessageTemplateDataSource

public class ClasspathResourceMessageTemplateDataSource extends SimpleMessageDataSource implements MessageTemplateDataSource
MessageTemplateDataSource based on a locale-specific classpath resource.

The getMessageTemplate() will load a classpath resource located at the resource path passed to the class constructor. The resource path must have a file extension, and first this method will insert _lang before the file extension and attempt to use that resource, where lang is the language value returned by Locale.getLanguage() on the Locale object passed to the class constructor.

If the language-specific resource is not found, it will try to use the resource path exactly as configured. If that resource cannot be found, a RuntimeException will be thrown.

  • Constructor Details

    • ClasspathResourceMessageTemplateDataSource

      public ClasspathResourceMessageTemplateDataSource(Locale locale, String subject, String resource, Map<String,?> model)
      Construct with values.
      Parameters:
      locale - the locale to use when locating the message resource
      subject - the subject to use
      resource - the resource path to the message template
      model - the mail merge model to use
  • Method Details