本文整理汇总了Java中org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl类的典型用法代码示例。如果您正苦于以下问题:Java StringResourceRepositoryImpl类的具体用法?Java StringResourceRepositoryImpl怎么用?Java StringResourceRepositoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringResourceRepositoryImpl类属于org.apache.velocity.runtime.resource.util包,在下文中一共展示了StringResourceRepositoryImpl类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TemplateEngine
import org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl; //导入依赖的package包/类
/**
* Constructs a new {@link TemplateEngine} object, and initializes it. This
* constructor will throw a {@link RuntimeException} if initializing fails.
*
* @param path The path containing all the templates.
* @param executor
*/
public TemplateEngine(Path path, ExecutorService executor) {
this.executor = executor;
try {
this.path = path;
this.modificationTimes = Maps.newHashMap();
this.engine = new VelocityEngine();
engine.setProperty("resource.loader", "string");
engine.setProperty("runtime.log.logsystem.class", getPath(NullLogChute.class));
engine.setProperty("string.resource.loader.class", getPath(StringResourceLoader.class));
engine.setProperty("string.resource.loader.description", "Velocity StringResource loader");
engine.setProperty("string.resource.loader.repository.class", getPath(StringResourceRepositoryImpl.class));
engine.init();
updateTemplates();
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
throw new DevHubException("Could not initialize the TemplateEngine", e);
}
}
示例2: initStringResourceRepository
import org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl; //导入依赖的package包/类
private StringResourceRepository initStringResourceRepository(Map<String, String> pathToTempalteMapping) throws IOException {
StringResourceRepository result = new StringResourceRepositoryImpl();
StringResourceLoader.setRepository(StringResourceLoader.REPOSITORY_NAME_DEFAULT, result);
registerResource(result, RuntimeConstants.VM_LIBRARY_DEFAULT, RuntimeConstants.VM_LIBRARY_DEFAULT);
for (Map.Entry<String, String> pathToTempalteMappingItem : pathToTempalteMapping.entrySet()) {
registerResource(result, pathToTempalteMappingItem.getKey(), pathToTempalteMappingItem.getValue());
}
return result;
}
示例3: PnResourceLoader
import org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl; //导入依赖的package包/类
public PnResourceLoader() {
repo = new StringResourceRepositoryImpl();
StringResourceLoader.setRepository(REPOSITORY_NAME_DEFAULT, repo);
}