org.apache.velocity.runtime.resource.ResourceManagerImpl Java Examples

The following examples show how to use org.apache.velocity.runtime.resource.ResourceManagerImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeGeneratorContext.java    From sundrio with Apache License 2.0 5 votes vote down vote up
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);
    }
}