下面列出了怎么用org.apache.velocity.runtime.resource.ResourceCacheImpl的API类实例代码及写法,或者点击链接到github查看源代码。
public CodeGeneratorContext(VelocityEngine velocityEngine, VelocityContext velocityContext) {
this.velocityEngine = velocityEngine;
this.velocityContext = velocityContext;
this.velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "string");
this.velocityEngine.setProperty("string.resource.loader.class", StringResourceLoader.class.getName());
//We are going to use shading so we need to make sure that the following configuration will be shade friendly...
this.velocityEngine.setProperty(RuntimeConstants.RESOURCE_MANAGER_CLASS, ResourceManagerImpl.class.getName());
this.velocityEngine.setProperty(RuntimeConstants.RESOURCE_MANAGER_CACHE_CLASS, ResourceCacheImpl.class.getName());
this.velocityEngine.setProperty(RuntimeConstants.PARSER_POOL_CLASS, ParserPoolImpl.class.getName());
this.velocityEngine.setProperty(RuntimeConstants.UBERSPECT_CLASSNAME, UberspectImpl.class.getName());
this.velocityEngine.setProperty("runtime.log.logsystem.class", SystemLogChute.class.getName());
ClassLoader current = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(VelocityEngine.class.getClassLoader());
this.velocityEngine.init();
//Load standard directives
this.velocityEngine.loadDirective(ClassDirective.class.getCanonicalName());
this.velocityEngine.loadDirective(MethodDirective.class.getCanonicalName());
this.velocityEngine.loadDirective(FieldDirective.class.getCanonicalName());
//Load utility directives
this.velocityEngine.loadDirective(PluralizeDirective.class.getCanonicalName());
this.velocityEngine.loadDirective(SingularizeDirective.class.getCanonicalName());
} finally {
Thread.currentThread().setContextClassLoader(current);
}
}