1
2
3
4 package ca.uhn.hl7v2.sourcegen.util;
5
6 import org.apache.velocity.Template;
7 import org.apache.velocity.app.VelocityEngine;
8 import org.apache.velocity.runtime.RuntimeConstants;
9
10
11
12
13
14
15
16
17
18
19
20 public class VelocityFactory
21 {
22
23
24
25 private VelocityFactory() {
26
27 }
28
29
30
31
32
33
34
35
36
37
38
39 public static Template getClasspathTemplateInstance(String theTemplate) throws Exception {
40 VelocityEngine engine = getEngineInstance();
41 return engine.getTemplate(theTemplate);
42 }
43
44
45
46
47
48 public static VelocityEngine getEngineInstance() {
49 VelocityEngine engine = new VelocityEngine();
50
51 engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
52 engine.setProperty("classpath." + RuntimeConstants.RESOURCE_LOADER + ".class", ResourceLoader.class
53 .getName());
54 engine.setProperty(RuntimeConstants.VM_LIBRARY, "");
55 engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, Boolean.TRUE);
56 engine.init();
57 engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, Boolean.TRUE);
58 return engine;
59 }
60
61 }