Added updatePrototypes() method to ScriptingEngine interface.

This commit is contained in:
hns 2002-06-21 15:28:40 +00:00
parent e47b5ca388
commit f3e9f21bb3
3 changed files with 29 additions and 10 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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