From f3e9f21bb35ec17ea7e156b50dbf6b2ead0de256 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 21 Jun 2002 15:28:40 +0000 Subject: [PATCH] Added updatePrototypes() method to ScriptingEngine interface. --- .../framework/core/RequestEvaluator.java | 10 ++++++++-- src/helma/scripting/ScriptingEngine.java | 9 ++++++++- src/helma/scripting/fesi/FesiEvaluator.java | 20 ++++++++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/helma/framework/core/RequestEvaluator.java b/src/helma/framework/core/RequestEvaluator.java index 13a3c321..3911f210 100644 --- a/src/helma/framework/core/RequestEvaluator.java +++ b/src/helma/framework/core/RequestEvaluator.java @@ -92,6 +92,9 @@ public final class RequestEvaluator implements Runnable { int tries = 0; boolean done = false; String error = null; + + scriptingEngine.updatePrototypes (); + while (!done) { currentElement = null; @@ -184,7 +187,6 @@ public final class RequestEvaluator implements Runnable { if (currentElement != null) { // add to requestPath array requestPath.add (currentElement); - String pt = app.getPrototypeName (currentElement); } } } @@ -325,6 +327,8 @@ public final class RequestEvaluator implements Runnable { globals.put ("res", res); globals.put ("app", app); + scriptingEngine.updatePrototypes (); + scriptingEngine.enterContext (globals); currentElement = root; @@ -370,13 +374,15 @@ public final class RequestEvaluator implements Runnable { // if thisObject is an instance of NodeHandle, get the node object itself. if (thisObject != null && thisObject instanceof NodeHandle) { thisObject = ((NodeHandle) thisObject).getNode (app.nmgr.safe); - // see if a valid node was returned + // see if a valid node was returned if (thisObject == null) { reqtype = NONE; break; } } + scriptingEngine.updatePrototypes (); + // avoid going into transaction if called function doesn't exist boolean functionexists = true; functionexists = scriptingEngine.hasFunction (thisObject, method); diff --git a/src/helma/scripting/ScriptingEngine.java b/src/helma/scripting/ScriptingEngine.java index 0da2fc7e..e53182d6 100644 --- a/src/helma/scripting/ScriptingEngine.java +++ b/src/helma/scripting/ScriptingEngine.java @@ -15,10 +15,17 @@ import java.io.File; */ public interface ScriptingEngine { + /** + * This method is called before an execution context for a request + * evaluation is entered to let the Engine know it should update + * its prototype information + */ + public void updatePrototypes (); + /** * This method is called when an execution context for a request * evaluation is entered. The globals parameter contains the global values - * to be applied during this executino context. + * to be applied during this execution context. */ public void enterContext (HashMap globals) throws ScriptingException; diff --git a/src/helma/scripting/fesi/FesiEvaluator.java b/src/helma/scripting/fesi/FesiEvaluator.java index fffc704a..b1572ceb 100644 --- a/src/helma/scripting/fesi/FesiEvaluator.java +++ b/src/helma/scripting/fesi/FesiEvaluator.java @@ -249,17 +249,15 @@ public final class FesiEvaluator implements ScriptingEngine { } } - - /** - * This method is called when an execution context for a request - * evaluation is entered. The globals parameter contains the global values - * to be applied during this executino context. + /** + * This method is called before an execution context is entered to let the + * engine know it should update its prototype information. */ - public void enterContext (HashMap globals) throws ScriptingException { + public void updatePrototypes () { // first loop through existing prototypes and update them if necessary for (Enumeration e=prototypes.elements(); e.hasMoreElements(); ) { TypeInfo info = (TypeInfo) e.nextElement (); - // only update prototype if it has already been initialized. + // only update prototype if it has already been initialized. // otherwise, this will be done on demand if (info.lastUpdate > 0) { Prototype p = app.typemgr.getPrototype (info.protoName); @@ -272,6 +270,14 @@ public final class FesiEvaluator implements ScriptingEngine { } } } + } + + /** + * This method is called when an execution context for a request + * evaluation is entered. The globals parameter contains the global values + * to be applied during this execution context. + */ + public void enterContext (HashMap globals) throws ScriptingException { // set globals on the global object if (globals != null && globals != lastGlobals) { // loop through global vars and set them