2020-11-07 11:56:38 -08:00
|
|
|
package com.wisemapping.util;
|
|
|
|
|
|
|
|
import org.apache.commons.collections.ExtendedProperties;
|
|
|
|
import org.apache.velocity.app.VelocityEngine;
|
2021-12-24 18:03:23 -08:00
|
|
|
import org.apache.velocity.runtime.RuntimeConstants;
|
2020-11-07 11:56:38 -08:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
public class VelocityEngineWrapper {
|
2021-12-24 18:03:23 -08:00
|
|
|
private final VelocityEngine velocityEngine;
|
2020-11-07 11:56:38 -08:00
|
|
|
|
|
|
|
public VelocityEngineWrapper() {
|
|
|
|
ExtendedProperties extendedProperties = new ExtendedProperties();
|
|
|
|
extendedProperties.setProperty("resource.loader", "class");
|
|
|
|
extendedProperties.setProperty("class.resource.loader.class",
|
|
|
|
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
|
|
|
|
|
|
|
this.velocityEngine = new VelocityEngine();
|
|
|
|
velocityEngine.setExtendedProperties(extendedProperties);
|
2021-12-24 18:03:23 -08:00
|
|
|
|
|
|
|
// Configure velocity to use log4j.
|
|
|
|
velocityEngine.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
|
|
|
|
"org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
|
|
|
|
velocityEngine.setProperty("runtime.log.logsystem.log4j.category", "org.apache.velocity");
|
|
|
|
|
2020-11-07 11:56:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
public VelocityEngine getVelocityEngine() {
|
|
|
|
return velocityEngine;
|
|
|
|
}
|
|
|
|
}
|