Package com.axelor.script
Class JavaScriptScriptHelper
java.lang.Object
com.axelor.script.AbstractScriptHelper
com.axelor.script.JavaScriptScriptHelper
- All Implemented Interfaces:
ScriptHelper,AutoCloseable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name a plain eval's source is reported under, in stack traces and script errors.Fields inherited from class com.axelor.script.AbstractScriptHelper
log -
Constructor Summary
ConstructorsConstructorDescriptionJavaScriptScriptHelper(Context context) JavaScriptScriptHelper(Bindings bindings) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Evaluate the given expression with the given bindings.Execute a compiled JS functionSource—(function(scope){ ... })— against an explicitscopeobject, returning a durable host value.static org.graalvm.polyglot.SourceA named, globally-cached JSSource.withTimeout(long timeout) Methods inherited from class com.axelor.script.AbstractScriptHelper
call, doCall, eval, getBindings, setBindings, test
-
Field Details
-
EVAL_NAME
The name a plain eval's source is reported under, in stack traces and script errors.- See Also:
-
-
Constructor Details
-
JavaScriptScriptHelper
-
JavaScriptScriptHelper
-
-
Method Details
-
jsSource
A named, globally-cached JSSource. Naming (e.g.workflow:<id>:script:<node>) improves stack traces and diagnostics. It shares the one source cache with plain evals, sized and expired byapplication.script.cache.sizeandexpire-time: while cached, the same Source is reused, so GraalVM reuses its parsed and compiled code across contexts on the shared engine. -
withTimeout
-
eval
Description copied from interface:ScriptHelperEvaluate the given expression with the given bindings.- Specified by:
evalin interfaceScriptHelper- Parameters:
expr- the expression to evaluatebindings- the context bindings- Returns:
- expression result
- Throws:
ScriptException
-
execute
Execute a compiled JS functionSource—(function(scope){ ... })— against an explicitscopeobject, returning a durable host value. The function is compiled once per this helper's context and reused; execution is wall-clock timeout-guarded likeeval(java.lang.String, javax.script.Bindings). -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-