Class ScriptManager

java.lang.Object
ecmwf.common.technical.ScriptManager
All Implemented Interfaces:
AutoCloseable

public final class ScriptManager extends Object implements AutoCloseable
The Class ScriptManager.
  • Field Details

  • Method Details

    • exec

      public static <T> T exec(String language, Map<String,Object> bindings, String scriptContent, ScriptManager.ScriptAction<T> action) throws ScriptException
      Exec. Use a cleaning executor service: a virtual-thread executor if experimental options are allowed, otherwise a platform-thread executor.
      Type Parameters:
      T - the generic type
      Parameters:
      language - the language
      bindings - the bindings
      scriptContent - the script content
      action - the action
      Returns:
      the t
      Throws:
      ScriptException - the script exception
    • exec

      public static <T> T exec(String language, Map<String,Object> bindings, String scriptContent, ScriptManager.ScriptAction<T> action, long timeoutMs) throws ScriptException
      Exec. Use a cleaning executor service: a virtual-thread executor if experimental options are allowed, otherwise a platform-thread executor.
      Type Parameters:
      T - the generic type
      Parameters:
      language - the language
      bindings - the bindings
      scriptContent - the script content
      action - the action
      timeoutMs - the timeout ms
      Returns:
      the result of type T
      Throws:
      ScriptException - the script exception
    • exec

      public static <T> T exec(Class<T> clazz, String defaultLanguage, Map<String,Object> bindings, String script) throws ScriptException
      Exec. If no language is specified in the header of the script then the default language is used (e.g. script=js:code or script=python:code). Also add a return is missing from the last expression of the script.
      Type Parameters:
      T - the generic type
      Parameters:
      clazz - the clazz
      defaultLanguage - the default language
      bindings - the bindings
      script - the script
      Returns:
      the t
      Throws:
      ScriptException - the script exception
    • exec

      public static <T> T exec(Class<T> clazz, String defaultLanguage, String script) throws ScriptException
      Exec. If no language is specified in the header of the script then the default language is used (e.g. script=js:code or script=python:code). Also add a return is missing from the last expression of the script.
      Type Parameters:
      T - the generic type
      Parameters:
      clazz - the clazz
      defaultLanguage - the default language
      script - the script
      Returns:
      the t
      Throws:
      ScriptException - the script exception
    • exec

      public static void exec(String defaultLanguage, String script) throws ScriptException
      Exec. If no language is specified in the header of the script then the default language is used (e.g. script=js:code or script=python:code).
      Parameters:
      defaultLanguage - the default language
      script - the script
      Throws:
      ScriptException - the script exception
    • eval

      public static <T> T eval(Class<T> clazz, org.graalvm.polyglot.Value value, String parameter) throws ScriptException
      Eval. Must be called on the same thread where the context was created, and the thread should support cleanup of thread-local variables.
      Type Parameters:
      T - the generic type
      Parameters:
      clazz - the clazz
      value - the value
      parameter - the parameter
      Returns:
      the t
      Throws:
      ScriptException - the script exception
    • close

      public void close()
      Close.
      Specified by:
      close in interface AutoCloseable