1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.creadur.tentacles;
18
19 import java.util.Properties;
20
21 import org.apache.velocity.app.VelocityEngine;
22 import org.apache.velocity.runtime.log.CommonsLogLogChute;
23
24 public final class Templates {
25
26 private final IOSystem ioSystem;
27 private final VelocityEngine engine;
28 private final TentaclesResources tentaclesResources;
29
30 public Templates(final Platform platform) {
31 this.ioSystem = platform.getIoSystem();
32 this.tentaclesResources = platform.getTentaclesResources();
33 final Properties properties = new Properties();
34 properties.setProperty("file.resource.loader.cache", "true");
35 properties.setProperty("resource.loader", "file, class");
36 properties.setProperty("class.resource.loader.description",
37 "Velocity Classpath Resource Loader");
38 properties
39 .setProperty("class.resource.loader.class",
40 "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
41 properties.setProperty("runtime.log.logsystem.class",
42 CommonsLogLogChute.class.getName());
43 properties.setProperty("runtime.log.logsystem.commons.logging.name",
44 Templates.class.getName());
45
46 this.engine = new VelocityEngine();
47 this.engine.init(properties);
48 }
49
50 public TemplateBuilder template(final String name) {
51 return new TemplateBuilder(name, this.ioSystem, this.engine,
52 this.tentaclesResources);
53 }
54 }