This time, it's about tools reading external resources. I'd like to:

1) have ImportSupport and ImportTool also be available in generic tools for absolute URLs, only the view versions being able to import a relative URL

2) have XmlTool inherit from ImportSupport, to homogenize its behavior with ImportTool

3) have a new generic JsonTool, in the same spirit

Example:

  #set($elements = $json.read("https://some.external.api/elements.json";))
  #foreach($element in $elements) ...

4) Put back XmlTool in the velocity-tools-generic module, using shading for the dom4j dependency. This is motivated by the fact that although dom4j-1.6.1.jar weights 446k, shading only needs 152k out of it. So it's a little loss for users not using the XmlTool, and a little gain for users using the XmlTool (see the exact figures in the appended annex). Not mentioning the gain in simplicity, one less jar...

5) have view versions of XmlTool and JsonTool, with the extra feature of being able to handle query POST parameters that are in text/json and text/xml format.

Example:

  javascript part:
  obj.foo = 'bar';
  $.post({
    url: "some.template",
    data: JSON.serialize(obj),
    success: function(data) { do something },
    error: function() { console.log("error"); },
    contentType: "application/json"
  });

  template part in some.template:
  ... $json.post.foo ...

That's a typical client to server communication scheme. Of course, it certainly needs sanitization somewhere, as every client-side submission, but it's another story.

---------

Annex: dom4j shading experiment features (which also shows some jar sizes evolution figures)

Here are the individual jar sizes:

(velocity-engine 1.5 383k)
---
velocity-engine 1.7 439k
dom4j-1.1 446k
velocity-tools 2.0 (generic) 189k
velocity-tools 2.0 (generic + view) 312k
---
velocity-engine 2.0 current RC 622k
velocity-tools-generic 3.0-SNAPSHOT 160k
velocity-tools-view 3.0-SNAPSHOT 99k
velocity-tools-xml 3.0-SNAPSHOT 14k
dom4j-1.6.1.jar 307k
velocity-tools-xml 3.0-SNAPSHOT with dom4j shading 166k

Here are Velocity + Tools configuration sizes:

Config engine 1.7 + generic tools 2.0 => 628k
Config engine 1.7 +    view tools 2.0 => 751k

Config engine 1.7 + generic tools 2.0 + dom4j 1.1 => 1079k
Config engine 1.7 +    view tools 2.0 + dom4j 1.1 => 1197k

Config engine 2.0 + generic tools 3.0 => 782k Config engine 2.0 + generic tools & xml tool 3.0 + unshaded dom4j 1.6.1 => 1103k Config engine 2.0 + generic tools & xml tool 3.0 + shaded dom4j 1.6.1 => 948k

Config engine 2.0 + view tools 3.0 => 881k Config engine 2.0 + view tools & xml tool 3.0 + unshaded dom4j 1.6.1 => 1202k
Config engine 2.0 + view tools & xml tool 3.0 + shaded dom4j 1.6.1 => 1047k

To put it in another way, with dom4j shading and XmlTool back into the generic tools (compared with the engine 2.0 + tools 3.0 config): - people not using the XmlTool will loose 166k, about +21% for generic tools users and +18% for view tools users - people using the XmlTool will gain 155k, about -14% for generic tools users and -13% for view tools users


  Claude


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to