Interface JavascriptEngine<E>

Type Parameters:
E - Specifies the type of javascript engine
All Known Implementing Classes:
GraalJS, J2V8

public interface JavascriptEngine<E>
Javascript engine interface, allows the use of a javascript engine to execute javascript code functions.
Since:
7.4
Author:
Jarno Huibers
  • Method Details

    • setGlobalAlias

      void setGlobalAlias(String alias)
      Parameters:
      alias - An identifier which describes the script(s) that are being executed.
    • startRuntime

      void startRuntime() throws JavascriptException
      Initialize the runtime for the specified engine
      Throws:
      JavascriptException
    • executeScript

      void executeScript(String script) throws JavascriptException
      Read the functions of a given javascript file
      Parameters:
      script - String containing the contents of the javascript file in which the function(s) to be executed are specified.
      Throws:
      JavascriptException
    • executeFunction

      Object executeFunction(String name, Object... parameters) throws JavascriptException
      Executes a javascript function and returns the result of that function
      Parameters:
      name - The name of the javascript function as given in the javascript file.
      parameters - An array containing the parameters for the javascript function, given in the adapter configuration
      Returns:
      The result of the javascript function is returned.
      Throws:
      JavascriptException
    • closeRuntime

      void closeRuntime()
      Closes the runtime for the specified engine
    • getEngine

      E getEngine()
      Getter for the runtime of the specified engine
      Returns:
      Returns the runtime instance
    • registerCallback

      void registerCallback(ISender sender, PipeLineSession session)
      Allows for senders to be called by the Javascript function. Sender needs to be given in the adapter configuration, a Javascript function can call the sender, using the name of the sender as a function call.
      Parameters:
      sender - The sender given in the adapter configuration
    • setResultHandler

      void setResultHandler(ResultHandler resultHandler)
      Registers the result and error functions to be handled by the given result handler.
      Parameters:
      resultHandler - Object to handle results and errors.