Interface ScriptInvocationHandler


public interface ScriptInvocationHandler
Implementations can be registered with a ScriptableDataSet to be called before and after script contained in a data set field is executed. This can be used to add commonly used import statements for all scripts of a given language or to post-process the result of a script execution.

Implementations must define a default constructor, if they shall be used as standard handler for a language.

  • Method Summary

    Modifier and Type
    Method
    Description
    Must return the name of the scripting language for which this handler can be registered, as expected by the JSR 223 scripting engine manager, e.g.
    Will be called after a script contained in a field of a data set is executed.
    preInvoke(String script)
    Will be called before a script contained in a field of a data set is executed.
    void
    Makes the scripting engine available to handler implementations.
  • Method Details

    • getLanguageName

      String getLanguageName()
      Must return the name of the scripting language for which this handler can be registered, as expected by the JSR 223 scripting engine manager, e.g. "jruby".
      Returns:
      The name of the scripting language.
    • preInvoke

      String preInvoke(String script)
      Will be called before a script contained in a field of a data set is executed.
      Parameters:
      script - The script to be executed.
      Returns:
      The script to be executed, enriched with common imports for example.
    • postInvoke

      Object postInvoke(Object object)
      Will be called after a script contained in a field of a data set is executed.
      Parameters:
      object - The result of the script execution.
      Returns:
      The result of the script execution, possibly modified by this handler.
    • setScriptEngine

      void setScriptEngine(ScriptEngine engine)
      Makes the scripting engine available to handler implementations.
      Parameters:
      engine - The scripting engine used to execute the current script.