10 Feb 06:50
[jira] [Created] (VELOCITY-817) Dynamic Templates with Caching
Mark S (Created) (JIRA <dev <at> velocity.apache.org>
2012-02-10 05:50:00 GMT
2012-02-10 05:50:00 GMT
Dynamic Templates with Caching
------------------------------
Key: VELOCITY-817
URL: https://issues.apache.org/jira/browse/VELOCITY-817
Project: Velocity
Issue Type: Improvement
Components: Engine
Affects Versions: 1.7
Reporter: Mark S
I thought I would share the following code with the Apache Velocity community.
Problem Description: I wanted to use Dynamic Templates though I found the following had massive
performance implications.
-- Velocity Call Snippet --
{code}
String template = "message.to: ${message.to} ";
StringWriter velocityWriter = new StringWriter();
velocityEngine.evaluate( velocityContext, velocityWriter, "LOG", template );
return velocityWriter.toString();
{code}
-- Velocity Call Snippet --
As such, I needed an alternate solution and guessed that if I could cache the Velocity templates used I could
see big performance gains.
I initially looked to the org.apache.velocity.runtime.resource.loader.StringResourceLoader class
to solve my problems. The StringResourceLoader class requires an instance of the
(Continue reading)
RSS Feed