Package groovy.text.markup
Class MarkupTemplateEngine.CachingTemplateResolver
- java.lang.Object
- 
- groovy.text.markup.MarkupTemplateEngine.DefaultTemplateResolver
- 
- groovy.text.markup.MarkupTemplateEngine.CachingTemplateResolver
 
 
- 
- All Implemented Interfaces:
- TemplateResolver
 - Enclosing class:
- MarkupTemplateEngine
 
 public static class MarkupTemplateEngine.CachingTemplateResolver extends MarkupTemplateEngine.DefaultTemplateResolver A template resolver which avoids callingClassLoader.getResource(String)if a template path already has been queried before. This improves performance if caching is enabled in the configuration.
- 
- 
Constructor SummaryConstructors 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.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(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.URLresolveTemplate(java.lang.String templatePath)Resolvers must implement this method in order to resolve a template, given a template path.
 
- 
- 
- 
Constructor Detail- 
CachingTemplateResolverpublic CachingTemplateResolver(java.util.Map<java.lang.String,java.net.URL> cache) Creates a new caching template resolver. The cache implementation being used depends on the use of the template engine. If multiple templates can be rendered in parallel, it must be using a thread-safe cache.- Parameters:
- cache- the backing cache
 
 - 
CachingTemplateResolverpublic CachingTemplateResolver() Creates a new caching template resolver using a concurrent hash map as the backing cache.
 
- 
 - 
Method Detail- 
configurepublic void configure(java.lang.ClassLoader templateClassLoader, TemplateConfiguration configuration)Description copied from interface:TemplateResolverThis method is called once the template engine is initialized, providing the resolver with the template engine configuration and its template class loader.- Specified by:
- configurein interface- TemplateResolver
- Overrides:
- configurein class- MarkupTemplateEngine.DefaultTemplateResolver
- Parameters:
- templateClassLoader- the classloader where templates will be searched for
- configuration- the configuration of the template engine
 
 - 
resolveTemplatepublic java.net.URL resolveTemplate(java.lang.String templatePath) throws java.io.IOExceptionDescription copied from interface:TemplateResolverResolvers must implement this method in order to resolve a template, given a template path. They must return a valid URL or an IOException.- Specified by:
- resolveTemplatein interface- TemplateResolver
- Overrides:
- resolveTemplatein class- MarkupTemplateEngine.DefaultTemplateResolver
- Parameters:
- templatePath- path to the template
- Returns:
- the template URL, that will be used to load the template
- Throws:
- java.io.IOException
 
 
- 
 
-