You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, this library is providing option to set java object as a JS global variable. It is not giving an option to set ScriptContext, which is very useful feature form nashorn library to scoping the script execution as below
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("nashorn");
// define a different script context
ScriptContext newContext = new SimpleScriptContext();
newContext.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
// set the variable to a different value in another scope
engineScope.put("x", "world");
// evaluate the same code but in a different script context (x = "world")
engine.eval("print(x)", newContext);
It would be very helpful if you expose the option to set the script context
The text was updated successfully, but these errors were encountered:
Hi,
Currently, this library is providing option to set java object as a JS global variable. It is not giving an option to set ScriptContext, which is very useful feature form nashorn library to scoping the script execution as below
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("nashorn");
// define a different script context
ScriptContext newContext = new SimpleScriptContext();
newContext.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
It would be very helpful if you expose the option to set the script context
The text was updated successfully, but these errors were encountered: