From 11022c42b606035975ef5291cd341d3bd4d2ff9f Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 27 Mar 2007 19:51:43 +0000 Subject: [PATCH] * Forward put()s from the thread scope to the shared scope during repository injection. Fixes bug 504. --- src/helma/scripting/rhino/GlobalObject.java | 9 ++++++++- src/helma/scripting/rhino/RhinoEngine.java | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/helma/scripting/rhino/GlobalObject.java b/src/helma/scripting/rhino/GlobalObject.java index baab721a..5d9d638d 100644 --- a/src/helma/scripting/rhino/GlobalObject.java +++ b/src/helma/scripting/rhino/GlobalObject.java @@ -108,7 +108,14 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder { public void put(String name, Scriptable start, Object value) { // register property for PropertyRecorder interface if (isRecording) { - changedProperties.add(name); + // if during compilation a property is set on the thread scope + // forward it to the shared scope (bug 504) + if (isThreadScope) { + core.global.put(name, core.global, value); + return; + } else { + changedProperties.add(name); + } } super.put(name, start, value); } diff --git a/src/helma/scripting/rhino/RhinoEngine.java b/src/helma/scripting/rhino/RhinoEngine.java index 4f2c5171..e9ba5eab 100644 --- a/src/helma/scripting/rhino/RhinoEngine.java +++ b/src/helma/scripting/rhino/RhinoEngine.java @@ -526,7 +526,16 @@ public class RhinoEngine implements ScriptingEngine { * @param resource a code resource */ public void injectCodeResource(String typename, Resource resource) { - core.injectCodeResource(typename, resource); + // we activate recording on thread scope to make it forward + // property puts to the shared scope (bug 504) + if (global != null) + global.startRecording(); + try { + core.injectCodeResource(typename, resource); + } finally { + if (global != null) + global.stopRecording(); + } } /**