Hi devs,

Rendering Tx are great to modify an XDOM into another XDOM. 

However they have a limitation: they’re slow (since you have to traverse the 
whole AST). So if you have 10 Tx, you traverse the AST 10 times…

I’d like to brainstorm about an alternative: the ability to register some 
Listener that will get executed at render time and that will transform the 
events.

Use cases
========

Here are some example of Tx that would benefit being rewritten using this 
mechanism:

* Icon Tx
* Auto linking of JIRA id to jira issues
* WikiWord Tx

Implementation
=============

It could be something like:

* Introduce a ConfigurableBlockRenderer interface with a addListener() method
* Modify AbstractBlockRenderer to execute those Listeners before it calls its 
PrintRenderer. This can be achieved with a composite listener that wraps the 
listeners added and the PrintRenderer.
* Have a way to register some Listeners in the configuration, that should be 
executed when a page is rendered
* Modify XWikiDocument so that those configured listeners are executed when 
rendering a page

Differences between Tx and Listeners
==============================

* Tx are slow but easy to write since you have access to the whole AST
* Listeners are harder to write since you need to store the events if you need 
to remember them (but we have developed some tools already over the years such 
as the LookaheadListener)
* Listeners depend on their order and they should be written carefully to 
minimize their interdependencies
* Listener will get executed only at render time so you need to render to get 
the modifications to the tree, while Tx are independent of rendering.

WDYT? Do you see a better way to achieve the same goal (ie removing the Tx 
performance limitation)?

Thanks
-Vincent

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to