use of freemarker.cache.URLTemplateLoader in project camel by apache.
the class SpringBootStarterMojo method getTemplate.
private Template getTemplate(String name) throws IOException {
Configuration cfg = new Configuration(Configuration.getVersion());
cfg.setTemplateLoader(new URLTemplateLoader() {
@Override
protected URL getURL(String name) {
return SpringBootStarterMojo.class.getResource("/" + name);
}
});
cfg.setDefaultEncoding("UTF-8");
Template template = cfg.getTemplate(name);
return template;
}
use of freemarker.cache.URLTemplateLoader in project camel by apache.
the class FreemarkerComponent method getConfiguration.
public synchronized Configuration getConfiguration() {
if (configuration == null) {
configuration = new Configuration();
configuration.setTemplateLoader(new URLTemplateLoader() {
@Override
protected URL getURL(String name) {
try {
return ResourceHelper.resolveMandatoryResourceAsUrl(getCamelContext().getClassResolver(), name);
} catch (Exception e) {
// so we should return null to signal the resource could not be found
return null;
}
}
});
}
return (Configuration) configuration.clone();
}
Aggregations