I use the Apache Commons Pool to create a pool of Nashorn engines. When I launch the application, I call preparePool()to warm the number of instances minIdleto eval()all the scripts in the engine so that it is ready to immediately answer calls invokeFunction().
preparePool()
minIdle
eval()
invokeFunction()
Warm up
@Override public NashornScriptEngine create() { // ... try { engine.eval(asset1); engine.eval(asset2); engine.eval(asset3); } // ... return engine; }
Depending on the size of the pool and the complexity of the pre-loaded scripts, this takes a considerable amount of time.
Questions
Can I heat up only one instance and safely clone it into the number of instances minIdle?
? ( - , )
( )
Nashorn . , ScriptEngine.createBindings() Bindings . , , Bindings ScriptEngine.eval(String|Reader, Bindings). ( ScriptContext, Bindings, out/err .)
ScriptEngine.createBindings()
Bindings
ScriptEngine.eval(String|Reader, Bindings)
ScriptContext
ScriptEngine . script script ( Compilable), -.
ScriptEngine
Compilable
Source: https://habr.com/ru/post/1615728/More articles:How to create empty folder in Google Cloud using Java API - google-cloud-storageWin console freezes after trying to clone git repository - gitПочему демоны называются демонами? - unixCreate an annotation instance in Kotlin - kotlinUnicodeEncodeError: 'charmap' с 'Ö', 'Ç' и т.д. - pythonWhat is better to use push or offset in bootstrap? - twitter-bootstrapFluid: Direct access to the value of the array returned by the view helper - fluidAdd individual selection in magenta - phpHow to reduce template code for web api calls? - c #почему буферный писатель не пишет сразу после вызова метода write() - javaAll Articles