ovidiu 2002/09/05 17:18:31
Modified: src/java/org/apache/cocoon/components/flow/javascript
JavaScriptInterpreter.java
Log:
Do an exec() on the compiledScript in enterContext() instead of doing
it every time in callFunction(). The exec() is also done only if the
scope is fresh, to preserve the values of global variables in scopes
maintained in the session scope.
Consistently name the Context objects in a similar way.
Revision Changes Path
1.8 +12 -7
xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java
Index: JavaScriptInterpreter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JavaScriptInterpreter.java 30 Aug 2002 00:55:12 -0000 1.7
+++ JavaScriptInterpreter.java 6 Sep 2002 00:18:31 -0000 1.8
@@ -226,6 +226,9 @@
((JSCocoon)cocoon).setInterpreter(this);
((JSCocoon)cocoon).setScope(thrScope);
thrScope.put("cocoon", thrScope, cocoon);
+
+ if (compiledScript != null)
+ compiledScript.exec(context, thrScope);
}
else
cocoon = (JSCocoon)thrScope.get("cocoon", thrScope);
@@ -259,9 +262,9 @@
try {
thrScope = enterContext(environment);
Reader reader = new BufferedReader(new InputStreamReader(is));
- Context ctx = Context.getCurrentContext();
+ Context context = Context.getCurrentContext();
- compiledScript = ctx.compileReader(thrScope, reader,
+ compiledScript = context.compileReader(thrScope, reader,
"(combined)", 1, null);
}
catch (Exception ex) {
@@ -362,9 +365,7 @@
try {
thrScope = enterContext(environment);
- Context cx = Context.getCurrentContext();
-
- compiledScript.exec(cx, thrScope);
+ Context context = Context.getCurrentContext();
JSCocoon cocoon = (JSCocoon)thrScope.get("cocoon", thrScope);
@@ -387,14 +388,14 @@
if (size != 0) {
for (int i = 0; i < size; i++) {
Interpreter.Argument arg = (Interpreter.Argument)params.get(i);
- funArgs[i] = ScriptRuntime.toObject(cx, thrScope, arg.value);
+ funArgs[i] = ScriptRuntime.toObject(context, thrScope, arg.value);
parameters.put(arg.name, parameters, arg.value);
}
}
cocoon.setParameters(parameters);
Object callFunArgs[] = { fun, funArgsArray };
- ((Function) callFunction).call(cx, thrScope, thrScope, callFunArgs);
+ ((Function) callFunction).call(context, thrScope, thrScope, callFunArgs);
}
catch (Exception ex) {
ex.printStackTrace();
@@ -448,6 +449,10 @@
try {
((Function)handleContFunction).call(context, kScope, kScope, args);
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
}
finally {
context.exit();
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]