Extend the scripting api to allow calls of methods defined in a script
----------------------------------------------------------------------
Key: SLING-320
URL: https://issues.apache.org/jira/browse/SLING-320
Project: Sling
Issue Type: New Feature
Components: Scripting
Reporter: Carsten Ziegeler
Assignee: Carsten Ziegeler
This is the suggestion as distilled from the mailing list:
a) Add the return value to the eval() method
b) Wwe create a new SlingScript.call(String method,
Object... args) method which will be implemented such, that a new
(virtual) script is created from the original script appended with the
method call.
Example: Let the script source be
function sampleFunction() {
...
}
function anotherFunction(arg1, arg2) {
...
}
Now, we call script.call("sampleFunction", null).
This would result in the virtual (combined) script:
function sampleFunction() {
...
}
function anotherFunction(arg1, arg2) {
...
}
sampleFunction();
Likewise, calling script.call("anotherFunction", 5, "astring") would get
the virtual script:
function sampleFunction() {
...
}
function anotherFunction(arg1, arg2) {
...
}
anotherFunction(5, "astring");
To build the method call, we may use the
ScriptEngineFactory.getMethodCallSyntax().
Finally the virtual script is actually evaluated.
This would also allow this for any scripting language ...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.