use of org.apache.velocity.runtime.log.NullLogChute in project auto by google.
the class TemplateTest method setUp.
@Before
public void setUp() {
velocityRuntimeInstance = new RuntimeInstance();
// Ensure that $undefinedvar will produce an exception rather than outputting $undefinedvar.
velocityRuntimeInstance.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, "true");
velocityRuntimeInstance.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, new NullLogChute());
// Disable any logging that Velocity might otherwise see fit to do.
velocityRuntimeInstance.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new NullLogChute());
velocityRuntimeInstance.init();
}
use of org.apache.velocity.runtime.log.NullLogChute in project tomee by apache.
the class Container method copyTemplateTo.
private void copyTemplateTo(final File targetDir, final String filename) throws Exception {
final File file = new File(targetDir, filename);
if (file.exists()) {
return;
}
// don't break apps using Velocity facade
final VelocityEngine engine = new VelocityEngine();
engine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new NullLogChute());
engine.setProperty(Velocity.RESOURCE_LOADER, "class");
engine.setProperty("class.resource.loader.description", "Velocity Classpath Resource Loader");
engine.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
engine.init();
final Template template = engine.getTemplate("/org/apache/tomee/configs/" + filename);
final VelocityContext context = new VelocityContext();
context.put("tomcatHttpPort", Integer.toString(configuration.getHttpPort()));
context.put("tomcatShutdownPort", Integer.toString(configuration.getStopPort()));
final Writer writer = new FileWriter(file);
template.merge(context, writer);
writer.flush();
writer.close();
}
Aggregations