Added updatePrototypes() method to ScriptingEngine interface.
This commit is contained in:
parent
e47b5ca388
commit
f3e9f21bb3
3 changed files with 29 additions and 10 deletions
|
@ -92,6 +92,9 @@ public final class RequestEvaluator implements Runnable {
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
String error = null;
|
String error = null;
|
||||||
|
|
||||||
|
scriptingEngine.updatePrototypes ();
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
|
||||||
currentElement = null;
|
currentElement = null;
|
||||||
|
@ -184,7 +187,6 @@ public final class RequestEvaluator implements Runnable {
|
||||||
if (currentElement != null) {
|
if (currentElement != null) {
|
||||||
// add to requestPath array
|
// add to requestPath array
|
||||||
requestPath.add (currentElement);
|
requestPath.add (currentElement);
|
||||||
String pt = app.getPrototypeName (currentElement);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,6 +327,8 @@ public final class RequestEvaluator implements Runnable {
|
||||||
globals.put ("res", res);
|
globals.put ("res", res);
|
||||||
globals.put ("app", app);
|
globals.put ("app", app);
|
||||||
|
|
||||||
|
scriptingEngine.updatePrototypes ();
|
||||||
|
|
||||||
scriptingEngine.enterContext (globals);
|
scriptingEngine.enterContext (globals);
|
||||||
|
|
||||||
currentElement = root;
|
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 is an instance of NodeHandle, get the node object itself.
|
||||||
if (thisObject != null && thisObject instanceof NodeHandle) {
|
if (thisObject != null && thisObject instanceof NodeHandle) {
|
||||||
thisObject = ((NodeHandle) thisObject).getNode (app.nmgr.safe);
|
thisObject = ((NodeHandle) thisObject).getNode (app.nmgr.safe);
|
||||||
// see if a valid node was returned
|
// see if a valid node was returned
|
||||||
if (thisObject == null) {
|
if (thisObject == null) {
|
||||||
reqtype = NONE;
|
reqtype = NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scriptingEngine.updatePrototypes ();
|
||||||
|
|
||||||
// avoid going into transaction if called function doesn't exist
|
// avoid going into transaction if called function doesn't exist
|
||||||
boolean functionexists = true;
|
boolean functionexists = true;
|
||||||
functionexists = scriptingEngine.hasFunction (thisObject, method);
|
functionexists = scriptingEngine.hasFunction (thisObject, method);
|
||||||
|
|
|
@ -15,10 +15,17 @@ import java.io.File;
|
||||||
*/
|
*/
|
||||||
public interface ScriptingEngine {
|
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
|
* This method is called when an execution context for a request
|
||||||
* evaluation is entered. The globals parameter contains the global values
|
* 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;
|
public void enterContext (HashMap globals) throws ScriptingException;
|
||||||
|
|
||||||
|
|
|
@ -249,17 +249,15 @@ public final class FesiEvaluator implements ScriptingEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* This method is called before an execution context is entered to let the
|
||||||
* This method is called when an execution context for a request
|
* engine know it should update its prototype information.
|
||||||
* evaluation is entered. The globals parameter contains the global values
|
|
||||||
* to be applied during this executino context.
|
|
||||||
*/
|
*/
|
||||||
public void enterContext (HashMap globals) throws ScriptingException {
|
public void updatePrototypes () {
|
||||||
// first loop through existing prototypes and update them if necessary
|
// first loop through existing prototypes and update them if necessary
|
||||||
for (Enumeration e=prototypes.elements(); e.hasMoreElements(); ) {
|
for (Enumeration e=prototypes.elements(); e.hasMoreElements(); ) {
|
||||||
TypeInfo info = (TypeInfo) e.nextElement ();
|
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
|
// otherwise, this will be done on demand
|
||||||
if (info.lastUpdate > 0) {
|
if (info.lastUpdate > 0) {
|
||||||
Prototype p = app.typemgr.getPrototype (info.protoName);
|
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
|
// set globals on the global object
|
||||||
if (globals != null && globals != lastGlobals) {
|
if (globals != null && globals != lastGlobals) {
|
||||||
// loop through global vars and set them
|
// loop through global vars and set them
|
||||||
|
|
Loading…
Add table
Reference in a new issue