Java Reference
In-Depth Information
Figure 3-5. State of ScriptEngineManager and three ScriptEngines after the third
ScriptEngine is created
Here is another twist to the so-called globalness of the global scope of
ScriptEngine s. This time, you will use the setBindings() method of a ScriptEngine to
set its global scope Bindings . Figure 3-6 shows the state of the ScriptEngineManager and
three ScriptEngines after the following snippet of code is executed:
// Set a new Bindings for the global scope of engine1
Bindings newGlobalEngine1 = new SimpleBindings();
newGlobalEngine1.put("n5", 500);
newGlobalEngine1.put("n6", 600);
engine1.setBindings(newGlobalEngine1, ScriptContext.GLOBAL_SCOPE);
Figure 3-6. State of ScriptEngineManager and Three ScriptEngines After a New Global
Scope Bindings Is Set for engine1
 
Search WWH ::




Custom Search