[ 
https://issues.apache.org/jira/browse/SLING-320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577477#action_12577477
 ] 

Carsten Ziegeler commented on SLING-320:
----------------------------------------

I added the return value to eval() and added a new call() method.

We can't use ScriptEngineFactory.getMethodCallSyntax() as this requires a java 
object to be called.

The current implementation tries javax.script.Invocable. If the underlying 
script engine does not support this (like our rhino impl) it just appends the 
method call as text - which obviously does not work for all languages and lacks 
proper type support.

> 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
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> 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.

Reply via email to