- We need the escaping API to be present in a velocity tool or script service so that it can be used from Velocity or any other scripting language used in a wiki page.
- However, we also need the escaping API to be present in a java POJO or component so that it can be called from java code. Java code must not call velocity tool nor script services. For example XCOMMONS-2534: Provide a method to escape content passed to wiki macro list parameters by manuelleduc · Pull Request #285 · xwiki/xwiki-commons · GitHub doesn’t seem good to me because it contains
XWiki21EscapeTool
which is only for velocity (unless there’s no need for an escaping API for other scripting language nor from java for this)
In summary velocity tool or script services need to call java component/POJO (unless for the case where the code is only for velocity and it’s not needed for other scripting languages or java).
Now re velocity tool vs script service, the answer is simple:
- If it’s useful for more than just velocity (i.e. for other scripting languages) then it must go in a script service. Otherwise it should go in a velocity tool.
Thanks