Share context/JS bindings
Tony Zakula
tonyzakula at gmail.com
Tue Jun 14 15:52:56 UTC 2016
Have you tried reusing the engine and only creating a new Context for every
run? Also, have you turned on caching for scripts as the engine parameter?
We have seen good performance doing that. Would be interested to know if
you do.
Thanks,
Tony
On Jun 14, 2016 4:58 AM, "Axel Dörfler" <axeld at pinc-software.de> wrote:
Hi Benjamin,
Am 14/06/2016 um 11:06 schrieb Benjamin Sieffert:
> I tried doing a similar thing for a while and found there is no pretty
> way to do it from the Java-side.
> I think the best solution is making your JS-code have no global state,
> by utilizing function scopes* and maybe small (custom, mutable)
> context objects that get passed around.
>
Yeah, it looks like I'll just have to document the fact for the time being,
and hope for future improvements :-)
Generally, the public API for providing bindings etc. certainly looks
> nice, but in practice I think some use-cases might just be too
> complicated to be supported.
>
I think having a low overhead solution to reusing contexts would be very
beneficial.
Another thing that I missed was Invocable supporting passing a
ScriptContext.
Thanks!
Bye,
Axel.
More information about the nashorn-dev
mailing list