public class ClassPathTemplateLocator extends PathTemplateLocator<String>
ClassPathTemplateLocator.Builder for
convenience.
Note that for a WAR archive, the classpath root is WEB-INF/classes (other
parts of the archive are not available). Consider using
org.trimou.servlet.locator.ServletContextTemplateLocator from
the trimou-extension-servlet.
By default, the locator will attempt to scan the classpath to get all
available template identifiers. However, only roots representing a directory
on a filesystem will be processed. The scanning of JARs and other sources is
not trivial. Moreover, it's legal for JARs to have no directory entries at
all. Scanning can be entirely disabled - see also
ClassPathTemplateLocator.Builder.setScanClasspath(boolean).
| Modifier and Type | Class and Description |
|---|---|
static class |
ClassPathTemplateLocator.Builder |
VIRTUAL_PATH_SEPARATOR_KEYconfigurationDEFAULT_PRIORITY| Constructor and Description |
|---|
ClassPathTemplateLocator(int priority,
String rootPath) |
ClassPathTemplateLocator(int priority,
String rootPath,
ClassLoader classLoader) |
ClassPathTemplateLocator(int priority,
String rootPath,
String suffix) |
ClassPathTemplateLocator(int priority,
String rootPath,
String suffix,
ClassLoader classLoader,
boolean scanClasspath) |
| Modifier and Type | Method and Description |
|---|---|
static ClassPathTemplateLocator.Builder |
builder() |
static ClassPathTemplateLocator.Builder |
builder(int priority) |
protected String |
constructVirtualPath(String source) |
Set<String> |
getAllIdentifiers()
This method should return an empty set if it's not possible to collect the names/identifiers.
|
Reader |
locate(String templateId)
The reader is always closed by the engine right after the template source is read.
|
addSuffix, getConfigurationKeys, getDefaultFileEncoding, getRealPathSeparator, getRootPath, getSuffix, getVirtualPathSeparator, init, stripSuffix, toRealPath, toStringgetPrioritycheckNotInitialized, initclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitinitpublic ClassPathTemplateLocator(int priority,
String rootPath)
priority - rootPath - If null, no templates will be available for precompilationpublic ClassPathTemplateLocator(int priority,
String rootPath,
String suffix)
priority - suffix - If null, a full template name must be usedrootPath - If null, no templates will be available for precompilationpublic ClassPathTemplateLocator(int priority,
String rootPath,
ClassLoader classLoader)
priority - rootPath - If null, no templates will be available for precompilationclassLoader - If null, use the TCCL or the CL of this classpublic ClassPathTemplateLocator(int priority,
String rootPath,
String suffix,
ClassLoader classLoader,
boolean scanClasspath)
priority - suffix - If null, a full template name must be usedrootPath - If null, no templates will be available for precompilationclassLoader - If null, use the TCCL or the CL of this classscanClasspath - If set to true the locator will attempt to scan
the classpath to get all available template identifiers.public Reader locate(String templateId)
TemplateLocatortemplateId - The template identifiernull if no available template with the given name
existsMustache.getName()public Set<String> getAllIdentifiers()
TemplateLocatorEngineConfigurationKey.PRECOMPILE_ALL_TEMPLATESprotected String constructVirtualPath(String source)
constructVirtualPath in class PathTemplateLocator<String>public static ClassPathTemplateLocator.Builder builder()
priority - public static ClassPathTemplateLocator.Builder builder(int priority)
priority - Copyright © 2017. All rights reserved.