jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Generama
  • GRA-6

Caching of JellyScript

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Labels:
    None

Description

The jelly scripts could be cached, improving the performance of plugins using the JellyTemplateEngine:

Index: src/main/java/org/generama/JellyTemplateEngine.java
===================================================================
RCS file: /home/projects/generama/scm/generama/src/main/java/org/generama/JellyTemplateEngine.java,v
retrieving revision 1.2
diff -u -r1.2 JellyTemplateEngine.java
— src/main/java/org/generama/JellyTemplateEngine.java 16 Jan 2005 13:40:48 -0000 1.2
+++ src/main/java/org/generama/JellyTemplateEngine.java 18 Oct 2005 20:42:11 -0000
@@ -2,6 +2,7 @@

import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXContentHandler;
@@ -10,6 +11,8 @@
import org.xml.sax.SAXException;

import java.io.Writer;
+import java.net.URL;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -21,7 +24,8 @@
public class JellyTemplateEngine extends AbstractTemplateEngine implements TemplateEngine {
private boolean supressdeclaration = false;
private boolean expandEmpty = false;
-
+ private Map scriptByUrl = new HashMap();
+
public final void generate(Writer out, Map contextObjects, String encoding, Class pluginClass) throws GeneramaException {
JellyContext context = new GeneramaJellyContext();
Set keys = contextObjects.keySet();
@@ -48,7 +52,14 @@

try {
xmlOutput.startDocument();

  • context.runScript(getScriptURL(pluginClass, ".jelly"), xmlOutput);
    +
    + URL scriptURL = getScriptURL(pluginClass, ".jelly");
    + Script script = (Script) scriptByUrl.get(scriptURL);
    + if (script == null) { + script = context.compileScript(scriptURL); + scriptByUrl.put(scriptURL, script); + }
    + script.run(context, xmlOutput);
    xmlOutput.endDocument();
    xmlWriter.write(saxHandler.getDocument());
    xmlWriter.flush();

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Diogo Bacelar Quintela added a comment - 19/Oct/05 4:46 AM

This doesn't solve the caching of (inner)called scripts.
I've looked there a couple weeks ago, i made some beta testing, but i then gave up.

Such feature should be a combination of caching at JellyTemplateEngine and at jelly context, and
assuming Script isn't mutable.

Maybe that's worth looking.

Show
Diogo Bacelar Quintela added a comment - 19/Oct/05 4:46 AM This doesn't solve the caching of (inner)called scripts. I've looked there a couple weeks ago, i made some beta testing, but i then gave up. Such feature should be a combination of caching at JellyTemplateEngine and at jelly context, and assuming Script isn't mutable. Maybe that's worth looking.
Hide
Permalink
Wolfgang Jung added a comment - 22/Oct/05 4:08 AM

In commons-jelly-1.1-SNAPSHOT there is method JellyContext.setCacheTags() added. But the jelly:import tag does not support any caching.

I've tried to patch the JellyImportTag so that the script is compiled only once but this fails because the context of the tags are changing. But this is an improvement belonging to commons-jelly.

Show
Wolfgang Jung added a comment - 22/Oct/05 4:08 AM In commons-jelly-1.1-SNAPSHOT there is method JellyContext.setCacheTags() added. But the jelly:import tag does not support any caching. I've tried to patch the JellyImportTag so that the script is compiled only once but this fails because the context of the tags are changing. But this is an improvement belonging to commons-jelly.

People

  • Assignee:
    Unassigned
    Reporter:
    Wolfgang Jung
Vote (0)
Watch (0)

Dates

  • Created:
    18/Oct/05 3:40 PM
    Updated:
    22/Oct/05 4:08 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.