String templatepath = crConf.getString(VELOCITY_TEMPLATE_KEY);
if (templatepath != null) {
File f = new File(templatepath);
if (f.exists()) {
try {
this.tpl = new FileTemplate(new FileInputStream(f));
} catch (FileNotFoundException e) {
log.error("Could not load template from " + templatepath, e);
} catch (CRException e) {
log.error("Could not load template from " + templatepath, e);
}
}
}
if (this.tpl == null) {
String templateName = this.getClass().getSimpleName() + ".vm";
try {
InputStream stream = this.getClass().getResourceAsStream(templateName);
this.tpl = new FileTemplate(stream);
} catch (Exception e) {
log.error("failed to load velocity template from " + templateName, e);
}
}
}