Renamed invoke methods to make their use clearer. Some minor code cleanup.
This commit is contained in:
parent
c0830be336
commit
f08e350367
2 changed files with 16 additions and 50 deletions
|
@ -560,7 +560,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
|
|
||||||
// get evaluator and invoke
|
// get evaluator and invoke
|
||||||
ev = getEvaluator();
|
ev = getEvaluator();
|
||||||
res = ev.invoke(req, session);
|
res = ev.invokeHttp(req, session);
|
||||||
}
|
}
|
||||||
} catch (ApplicationStoppedException stopped) {
|
} catch (ApplicationStoppedException stopped) {
|
||||||
// let the servlet know that this application has gone to heaven
|
// let the servlet know that this application has gone to heaven
|
||||||
|
@ -1332,7 +1332,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
// as first thing, invoke function onStart in the root object
|
// as first thing, invoke function onStart in the root object
|
||||||
RequestEvaluator eval = getEvaluator();
|
RequestEvaluator eval = getEvaluator();
|
||||||
try {
|
try {
|
||||||
eval.invokeFunction((INode) null, "onStart", new Object[0]);
|
eval.invokeInternal(null, "onStart", new Object[0]);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
logEvent("Error in " + name + "/onStart(): " + ignore);
|
logEvent("Error in " + name + "/onStart(): " + ignore);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1377,7 +1377,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
try {
|
try {
|
||||||
Object[] param = { session.getSessionID() };
|
Object[] param = { session.getSessionID() };
|
||||||
|
|
||||||
eval.invokeFunction(userhandle, "onLogout", param);
|
eval.invokeInternal(userhandle, "onLogout", param);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1439,7 +1439,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
r.start();
|
r.start();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
thisEvaluator.invokeFunction(null, j.getFunction(),
|
thisEvaluator.invokeInternal(null, j.getFunction(),
|
||||||
new Object[0], j.getTimeout());
|
new Object[0], j.getTimeout());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logEvent("error running " + j + ": " + ex.toString());
|
logEvent("error running " + j + ": " + ex.toString());
|
||||||
|
@ -1889,7 +1889,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
thisEvaluator.invokeFunction(null, job.getFunction(),
|
thisEvaluator.invokeInternal(null, job.getFunction(),
|
||||||
new Object[0], job.getTimeout());
|
new Object[0], job.getTimeout());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// gets logged in RequestEvaluator
|
// gets logged in RequestEvaluator
|
||||||
|
|
|
@ -448,7 +448,7 @@ public final class RequestEvaluator implements Runnable {
|
||||||
|
|
||||||
currentElement = root;
|
currentElement = root;
|
||||||
|
|
||||||
if (method.indexOf(".") > -1) {
|
if (method.indexOf('.') > -1) {
|
||||||
StringTokenizer st = new StringTokenizer(method, ".");
|
StringTokenizer st = new StringTokenizer(method, ".");
|
||||||
int cnt = st.countTokens();
|
int cnt = st.countTokens();
|
||||||
|
|
||||||
|
@ -513,10 +513,14 @@ public final class RequestEvaluator implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
// this only works for the (common) case that method is a plain
|
||||||
|
// method name, not an obj.method path
|
||||||
|
if (method.indexOf('.') < 0) {
|
||||||
|
functionexists = scriptingEngine.hasFunction(thisObject, method);
|
||||||
|
}
|
||||||
|
|
||||||
if (!functionexists) {
|
if (!functionexists) {
|
||||||
// function doesn't exist, nothing to do here.
|
// function doesn't exist, nothing to do here.
|
||||||
|
@ -643,7 +647,7 @@ public final class RequestEvaluator implements Runnable {
|
||||||
*
|
*
|
||||||
* @throws Exception ...
|
* @throws Exception ...
|
||||||
*/
|
*/
|
||||||
public synchronized ResponseTrans invoke(RequestTrans req, Session session)
|
public synchronized ResponseTrans invokeHttp(RequestTrans req, Session session)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
this.reqtype = HTTP;
|
this.reqtype = HTTP;
|
||||||
this.req = req;
|
this.req = req;
|
||||||
|
@ -750,11 +754,11 @@ public final class RequestEvaluator implements Runnable {
|
||||||
*
|
*
|
||||||
* @throws Exception ...
|
* @throws Exception ...
|
||||||
*/
|
*/
|
||||||
public synchronized Object invokeFunction(Object object, String functionName,
|
public synchronized Object invokeInternal(Object object, String functionName,
|
||||||
Object[] args)
|
Object[] args)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// give internal call more time (15 minutes) to complete
|
// give internal call more time (15 minutes) to complete
|
||||||
return invokeFunction(object, functionName, args, 60000L * 15);
|
return invokeInternal(object, functionName, args, 60000L * 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -769,7 +773,7 @@ public final class RequestEvaluator implements Runnable {
|
||||||
*
|
*
|
||||||
* @throws Exception ...
|
* @throws Exception ...
|
||||||
*/
|
*/
|
||||||
public synchronized Object invokeFunction(Object object, String functionName,
|
public synchronized Object invokeInternal(Object object, String functionName,
|
||||||
Object[] args, long timeout)
|
Object[] args, long timeout)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
reqtype = INTERNAL;
|
reqtype = INTERNAL;
|
||||||
|
@ -798,44 +802,6 @@ public final class RequestEvaluator implements Runnable {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param session ...
|
|
||||||
* @param functionName ...
|
|
||||||
* @param args ...
|
|
||||||
*
|
|
||||||
* @return ...
|
|
||||||
*
|
|
||||||
* @throws Exception ...
|
|
||||||
*/
|
|
||||||
public synchronized Object invokeFunction(Session session, String functionName,
|
|
||||||
Object[] args)
|
|
||||||
throws Exception {
|
|
||||||
reqtype = INTERNAL;
|
|
||||||
this.session = session;
|
|
||||||
thisObject = null;
|
|
||||||
method = functionName;
|
|
||||||
this.args = args;
|
|
||||||
res = new ResponseTrans();
|
|
||||||
result = null;
|
|
||||||
exception = null;
|
|
||||||
|
|
||||||
checkThread();
|
|
||||||
wait(app.requestTimeout);
|
|
||||||
|
|
||||||
if (reqtype != NONE) {
|
|
||||||
stopThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset res for garbage collection (res.data may hold reference to evaluator)
|
|
||||||
res = null;
|
|
||||||
|
|
||||||
if (exception != null) {
|
|
||||||
throw (exception);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getChildElement(Object obj, String name) throws ScriptingException {
|
private Object getChildElement(Object obj, String name) throws ScriptingException {
|
||||||
if (scriptingEngine.hasFunction(obj, "getChildElement")) {
|
if (scriptingEngine.hasFunction(obj, "getChildElement")) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue