Class ScriptManager
java.lang.Object
ecmwf.common.technical.ScriptManager
- All Implemented Interfaces:
AutoCloseable
The Class ScriptManager.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe Interface ScriptAction. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close.static <T> TEval.static <T> TExec.static <T> TExec.static voidExec.static <T> Texec(String language, Map<String, Object> bindings, String scriptContent, ScriptManager.ScriptAction<T> action) Exec.static <T> Texec(String language, Map<String, Object> bindings, String scriptContent, ScriptManager.ScriptAction<T> action, long timeoutMs) Exec.
-
Field Details
-
JS
-
PYTHON
-
-
Method Details
-
exec
public static <T> T exec(String language, Map<String, Object> bindings, String scriptContent, ScriptManager.ScriptAction<T> action) throws ScriptExceptionExec. 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 languagebindings- the bindingsscriptContent- the script contentaction- 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 ScriptExceptionExec. 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 languagebindings- the bindingsscriptContent- the script contentaction- the actiontimeoutMs- 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 ScriptExceptionExec. 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 clazzdefaultLanguage- the default languagebindings- the bindingsscript- 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 clazzdefaultLanguage- the default languagescript- the script- Returns:
- the t
- Throws:
ScriptException- the script exception
-
exec
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 languagescript- 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 clazzvalue- the valueparameter- the parameter- Returns:
- the t
- Throws:
ScriptException- the script exception
-
close
-