* Perform sanity checks for INTERNAL calls before reaching the central switch statement

in run() so we can start and stop transactions where we used to.
* Do not check for null arguments in invokeDirectFunction(), it's up to the caller to pass
   an empty array.
This commit is contained in:
hns 2006-01-13 11:22:47 +00:00
parent 4c50f96e3e
commit 752966cb47

View file

@ -131,9 +131,6 @@ public final class RequestEvaluator implements Runnable {
// while this thread is serving requests
while (localrtx == rtx) {
// root object reference
Object root;
// object reference to ressolve request path
Object currentElement;
@ -160,17 +157,31 @@ public final class RequestEvaluator implements Runnable {
// update scripting prototypes
scriptingEngine.updatePrototypes();
// avoid going into transaction if called function doesn't exist.
// this only works for the (common) case that method is a plain
// method name, not an obj.method path
if (reqtype == INTERNAL &&
functionName.indexOf('.') < 0 &&
!scriptingEngine.hasFunction(thisObject, functionName)) {
done = true;
reqtype = NONE;
break;
}
// Transaction name is used for logging etc.
StringBuffer txname = new StringBuffer(app.getName());
txname.append(":").append(req.getMethod().toLowerCase()).append(":");
txname.append((error == null) ? req.getPath() : "error");
String action = null;
root = app.getDataRoot();
// begin transaction
localrtx.begin(txname.toString());
Object root = app.getDataRoot();
initGlobals(root, requestPath);
String action = null;
if (error != null) {
res.error = error;
}
@ -178,9 +189,6 @@ public final class RequestEvaluator implements Runnable {
switch (reqtype) {
case HTTP:
// begin transaction
localrtx.begin(txname.toString());
if (session.message != null) {
// bring over the message from a redirect
res.message = session.message;
@ -387,9 +395,6 @@ public final class RequestEvaluator implements Runnable {
case XMLRPC:
case EXTERNAL:
// begin transaction
localrtx.begin(txname.toString());
try {
currentElement = root;
@ -448,34 +453,6 @@ public final class RequestEvaluator implements Runnable {
case INTERNAL:
// 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
if (thisObject == null) {
reqtype = NONE;
done = true;
break;
}
}
// avoid going into transaction if called function doesn't exist.
boolean functionexists = true;
// this only works for the (common) case that method is a plain
// method name, not an obj.method path
if (functionName.indexOf('.') < 0) {
functionexists = scriptingEngine.hasFunction(thisObject, functionName);
}
if (!functionexists) {
// function doesn't exist, nothing to do here.
reqtype = NONE;
} else {
// begin transaction
localrtx.begin(txname.toString());
try {
// reset skin recursion detection counter
skinDepth = 0;
@ -500,7 +477,6 @@ public final class RequestEvaluator implements Runnable {
this.exception = x;
}
}
done = true;
break;
@ -508,7 +484,7 @@ public final class RequestEvaluator implements Runnable {
} // switch (reqtype)
} catch (AbortException x) {
// res.abort() just aborts the transaction and
// leaves the respons untouched
// leaves the response untouched
abortTransaction();
done = true;
} catch (ConcurrencyException x) {
@ -839,9 +815,6 @@ public final class RequestEvaluator implements Runnable {
*/
public Object invokeDirectFunction(Object obj, String functionName, Object[] args)
throws Exception {
if (args == null) {
args = EMPTY_ARGS;
}
return scriptingEngine.invoke(obj, functionName, args,
ScriptingEngine.ARGS_WRAP_DEFAULT, false);
}
@ -878,6 +851,14 @@ public final class RequestEvaluator implements Runnable {
Object[] args, long timeout)
throws Exception {
initObjects(functionName, INTERNAL, RequestTrans.INTERNAL);
// if object is an instance of NodeHandle, get the node object itself.
if (object instanceof NodeHandle) {
object = ((NodeHandle) thisObject).getNode(app.nmgr.safe);
// If no valid node object return immediately
if (object == null) {
return null;
}
}
thisObject = object;
this.functionName = functionName;
this.args = args;