TemplateResolverpublic 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 | Description |
|---|---|---|
protected java.util.Map<java.lang.String,java.net.URL> |
cache |
|
protected boolean |
useCache |
| Constructor | Description |
|---|---|
CachingTemplateResolver() |
Creates a new caching template resolver using a concurrent hash map as the backing cache.
|
CachingTemplateResolver(java.util.Map<java.lang.String,java.net.URL> cache) |
Creates a new caching template resolver.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
configure(java.lang.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.
|
java.net.URL |
resolveTemplate(java.lang.String templatePath) |
Resolvers must implement this method in order to resolve a template, given a template path.
|
protected final java.util.Map<java.lang.String,java.net.URL> cache
protected boolean useCache
public CachingTemplateResolver(java.util.Map<java.lang.String,java.net.URL> cache)
cache - the backing cachepublic CachingTemplateResolver()
public void configure(java.lang.ClassLoader templateClassLoader,
TemplateConfiguration configuration)
TemplateResolverconfigure in interface TemplateResolverconfigure in class MarkupTemplateEngine.DefaultTemplateResolvertemplateClassLoader - the classloader where templates will be searched forconfiguration - the configuration of the template enginepublic java.net.URL resolveTemplate(java.lang.String templatePath)
throws java.io.IOException
TemplateResolverresolveTemplate in interface TemplateResolverresolveTemplate in class MarkupTemplateEngine.DefaultTemplateResolvertemplatePath - path to the templatejava.io.IOException