Easier way to process against a string as template?
I'm wondering if there is an easier way of running TemplateEngine.process(..) against a String parameter.
For an Email feature for a client I have implemented an entity which is persistet inside a database, so the client is able to define the notification templates at runtime as he desires.
This all works fine BUT probably there is a simpler solution then my current implementation?
Here's what I did to resolve a dynamic template:
- Create a second (Spring) TemplateEngine
- Register a MailTemplateResolver for the TemplateEngine
- Register a MailTemplateResourceResolver for the MailTemplate Resolver
The MailTemplateResourceResolver uses a ThreadLocal<String> containing the dynamic Template loaded from the database and provides a setter and a remove method for it.