public static class MarkupTemplateEngine.CachingTemplateResolver extends MarkupTemplateEngine.DefaultTemplateResolver
ClassLoader.getResource(String)
if a template path already has
been queried before. This improves performance if caching is enabled in the configuration.Modifier and Type | Field and Description |
---|---|
protected Map<String,URL> |
cache |
protected boolean |
useCache |
Constructor and Description |
---|
CachingTemplateResolver()
Creates a new caching template resolver using a concurrent hash map as the backing cache.
|
CachingTemplateResolver(Map<String,URL> cache)
Creates a new caching template resolver.
|
Modifier and Type | Method and Description |
---|---|
void |
configure(ClassLoader templateClassLoader,
TemplateConfiguration configuration)
This method is called once the template engine is initialized, providing the resolver with the
template engine configuration and its template class loader.
|
URL |
resolveTemplate(String templatePath)
Resolvers must implement this method in order to resolve a template, given a template path.
|
public CachingTemplateResolver(Map<String,URL> cache)
cache
- the backing cachepublic CachingTemplateResolver()
public void configure(ClassLoader templateClassLoader, TemplateConfiguration configuration)
TemplateResolver
configure
in interface TemplateResolver
configure
in class MarkupTemplateEngine.DefaultTemplateResolver
templateClassLoader
- the classloader where templates will be searched forconfiguration
- the configuration of the template enginepublic URL resolveTemplate(String templatePath) throws IOException
TemplateResolver
resolveTemplate
in interface TemplateResolver
resolveTemplate
in class MarkupTemplateEngine.DefaultTemplateResolver
templatePath
- path to the templateIOException