title: sms/email template manipulation in an intentional service
body: <p>I am preparing message(sms) templates in my spring application. It is relatively easy to do with apache velocity. A simply case (template + code) can look in that way:</p>
  
  <p><em>message.vsl</em></p>
  
  <pre><code>    Dear $lastName $firstName,
  Welcome to ServiceXYZ. Your registration with $phoneNumber is being processed.
  </code></pre>
  
  <p><em>java class(based on <a href="https://topriddy.wordpress.com/2012/02/23/how-to-generate-emails-sms-and-other-messages-from-templates-in-java/" rel="nofollow noreferrer">https://topriddy.wordpress.com/2012/02/23/how-to-generate-emails-sms-and-other-messages-from-templates-in-java/</a> ):</em></p>
  
  <pre><code>public String getRegistrationMail2(String lastName, String firstName, String phoneNumber) {
         Properties props = new Properties();
         props.put("resource.loader", "class");
         props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
  
         VelocityEngine ve = new VelocityEngine();
         ve.init(props);
  
         Map params = new HashMap();
         params.put("lastName",lastName );
         params.put("firstName", firstName);
         params.put("phoneNumber", phoneNumber);
  
  
         Template t = ve.getTemplate("/message.vsl");
         VelocityContext context = new VelocityContext(params);
         StringWriter writer = new StringWriter();
         t.merge(context, writer);
         return writer.toString();
     }
  </code></pre>
  
  <p>However business needs require my templates to become more complex. I would need to have a masked phoneNumber. Moreover the class above will become more generic - it will be a service(let's call it a template service) which will be called by other services(clients). And it will get a list of parameters which should be placed into the templates. Moreover the templates will be stored in database.</p>
  
  <p>As I do not want clients to mask the phone before calling my service how can the masking be achieved on the template service side ?
  I am guessing that I need to incorporate some VTL script into my code. If that's the case how can I achieve it ?</p>
  
  <p>thank you ! </p>