Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-320

Extend the scripting api to allow calls of methods defined in a script

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • Scripting
    • None

    Description

      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 ...

      Attachments

        Activity

          People

            Unassigned Unassigned
            cziegeler Carsten Ziegeler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: