Template t = cachedTemplateMap.get(cacheKey);
if (t != null) {
return t;
}
logger.info("Initializing template " + path);
TemplateInfo info = searchResource("/", LocalizeUtil.getCandidatePaths(path, locale));
InputStream input = info.getInput();
if (input == null) {
// TODO mayby we should return a null? So that caller can
// identify the situation of template load error or template not
// found.
throw new TemplateException(String.format("Template %s not found.", path));
}
t = new Template(info.getPath(), input);
cachedTemplateMap.put(cacheKey, t);
return t;
} catch (Exception e) {
throw new TemplateException(path + " resolve error", e);
}