{"action":"created","issue":{"url":"https://api.github.com/repos/coveo/nashorn-commonjs-modules/issues/12","repository_url":"https://api.github.com/repos/coveo/nashorn-commonjs-modules","labels_url":"https://api.github.com/repos/coveo/nashorn-commonjs-modules/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/coveo/nashorn-commonjs-modules/issues/12/comments","events_url":"https://api.github.com/repos/coveo/nashorn-commonjs-modules/issues/12/events","html_url":"https://github.com/coveo/nashorn-commonjs-modules/issues/12","id":189170766,"number":12,"title":"How Best to Use in Servlet Environment?","user":{"login":"mfreeman-xtivia","id":10734467,"avatar_url":"https://avatars.githubusercontent.com/u/10734467?v=3","gravatar_id":"","url":"https://api.github.com/users/mfreeman-xtivia","html_url":"https://github.com/mfreeman-xtivia","followers_url":"https://api.github.com/users/mfreeman-xtivia/followers","following_url":"https://api.github.com/users/mfreeman-xtivia/following{/other_user}","gists_url":"https://api.github.com/users/mfreeman-xtivia/gists{/gist_id}","starred_url":"https://api.github.com/users/mfreeman-xtivia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfreeman-xtivia/subscriptions","organizations_url":"https://api.github.com/users/mfreeman-xtivia/orgs","repos_url":"https://api.github.com/users/mfreeman-xtivia/repos","events_url":"https://api.github.com/users/mfreeman-xtivia/events{/privacy}","received_events_url":"https://api.github.com/users/mfreeman-xtivia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-14T17:15:43Z","updated_at":"2016-11-21T13:01:05Z","closed_at":null,"body":"This is really a question--what is the best/right way to use this Require module in a multi-threaded servlet environment??\r\n\r\nSo believing based on what I've read that the Nashorn engine itself is threadsafe, I create a single one of those in my servlet init().\r\n\r\nThen on each request/thread i create new bindings, map in Java objects to be exposed to the script(s), and then do engine.eval(mainscript,newbindings). \r\n\r\nThe challenge/question is where in that sequence do I put the Require.enable(engine)? once at init? It doesn't seem like Require class exposes a flavor of enable where i could pass in the bindings (global) i want it to use?"},"comment":{"url":"https://api.github.com/repos/coveo/nashorn-commonjs-modules/issues/comments/261930946","html_url":"https://github.com/coveo/nashorn-commonjs-modules/issues/12#issuecomment-261930946","issue_url":"https://api.github.com/repos/coveo/nashorn-commonjs-modules/issues/12","id":261930946,"user":{"login":"malaporte","id":1826047,"avatar_url":"https://avatars.githubusercontent.com/u/1826047?v=3","gravatar_id":"","url":"https://api.github.com/users/malaporte","html_url":"https://github.com/malaporte","followers_url":"https://api.github.com/users/malaporte/followers","following_url":"https://api.github.com/users/malaporte/following{/other_user}","gists_url":"https://api.github.com/users/malaporte/gists{/gist_id}","starred_url":"https://api.github.com/users/malaporte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malaporte/subscriptions","organizations_url":"https://api.github.com/users/malaporte/orgs","repos_url":"https://api.github.com/users/malaporte/repos","events_url":"https://api.github.com/users/malaporte/events{/privacy}","received_events_url":"https://api.github.com/users/malaporte/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T13:01:05Z","updated_at":"2016-11-21T13:01:05Z","body":"Ah indeed I kinda missed that the engine was being passed to `Module`. Slightly more complex, but probably OK in the end.\r\n\r\nOne thing to know keep in mind though: even if you are re-using the same engine across all threads, you'll still need to start with new bindings for each request, meaning that each JS file you `require` will need to be parsed & executed each time. That's still pretty intense...\r\n\r\nIn our case, we maintain a pool of engines & bindings, accepting the fact that globals might be re-used across several requests, which is not problematic in the context where we're using it."}}
{"actor":{"display_login":"malaporte"}}