Side navigation
#1454 closed enhancement (wontfix)
Opened August 01, 2007 09:44PM UTC
Closed January 24, 2008 06:21PM UTC
Last modified March 15, 2012 05:08PM UTC
Use Rhino scoping
Reported by: | joern | Owned by: | joern |
---|---|---|---|
Priority: | minor | Milestone: | 1.1.4 |
Component: | web | Version: | 1.1.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Currently the complete global functions and properties for a Rhino context are created for each request. It should be possible to leverage Rhino scoping API to create shared globals only once (eg. at application start) and reuse them (as a sealed parent scope?) on each request.
This is the current initialiazation, executed for each request:
ScriptableObject scope = new ImporterTopLevel(Context.enter()); Context.getCurrentContext().setErrorReporter(new ToolErrorReporter(true, System.err)); Globals.init(scope, request.getContextPath(), realPath(), page(request), request.getMethod().toLowerCase()); eval(scope, "blog"); Object result = eval(scope, page(request)); response.getWriter().write(result.toString()); Context.exit();
Creating and exiting the thread-bound context should be kept, but perhaps the global-Scope can be created once and then passed to the request-scope creation as the parent.
A shared scope implemented in a servlet: