George Moschovitis wrote:
You'd rather have one top-level scope per script execution. Otherwise, all threads would share their top-level variables (incl. JS built-in objects).

that's what I thought.

I guess the key thing here is what is meant by "script execution" in the context of http requests. The way we've used Rhino previously was to execute a script once per http request, whilst having a persistent top level scope to avoid the cost of initStandardObjects().

However, we're now trying a different approach with one long running rhino script / scope thing. The http server calls a rhino function in this scope from Java land, and the rhino function writes to the response output stream. By long running I mean the equal to the life of parent http server. Actually, longer, since the javascript starts the http server itself.

Rhino creates a new Context for each http request, automatically, I'm guessing this is because http servers ensure that each thread is scrubbed before being reused for another http request.

This approach implies that the javascript must watch out for thread safety (instance variables etc) but that's the same as for Servlet java.

Assuming that the javacript is trusted, is there anything *wrong* with this setup?

Patrick

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to