in flow/src/java/org/apache/struts/flow/core/javascript/fom/FOM_JavaScriptInterpreter.java [891:982]
public Object handleContinuation(String id, List params,
WebContext webctx) throws Exception
{
Object ret = null;
WebContinuation wk = continuationsMgr.lookupWebContinuation(id, getInterpreterID(), webctx);
if (wk == null) {
/*
* Throw an InvalidContinuationException to be handled inside the
* <map:handle-errors> sitemap element.
*/
throw new InvalidContinuationException("The continuation ID " + id + " is invalid.");
}
Context context = Context.enter();
context.setOptimizationLevel(OPTIMIZATION_LEVEL);
context.setGeneratingDebug(true);
context.setCompileFunctionsWithDynamicScope(true);
LocationTrackingDebugger locationTracker = new LocationTrackingDebugger();
if (wrapFactory != null) {
context.setWrapFactory(wrapFactory);
}
if (!enableDebugger) {
//FIXME: add a "tee" debugger that allows both to be used simultaneously
context.setDebugger(locationTracker, null);
}
// Obtain the continuation object from it, and setup the
// FOM_Flow object associated in the dynamic scope of the saved
// continuation with the environment and context objects.
Continuation k = (Continuation)wk.getContinuation();
ThreadScope kScope = (ThreadScope)k.getParentScope();
synchronized (kScope) {
ClassLoader savedClassLoader =
Thread.currentThread().getContextClassLoader();
FOM_Flow flow = null;
try {
Thread.currentThread().setContextClassLoader(kScope.getClassLoader());
flow = (FOM_Flow)kScope.get("flow", kScope);
kScope.setLock(true);
flow.pushCallContext(this, webctx, getLogger(), wk);
// Register the current scope for scripts indirectly called from this function
//FOM_JavaScriptFlowHelper.setFOM_FlowScope(flow.getObjectModel(), kScope);
if (enableDebugger) {
getDebugger().setVisible(true);
}
Scriptable parameters = context.newObject(kScope);
int size = params != null ? params.size() : 0;
for (int i = 0; i < size; i++) {
Interpreter.Argument arg = (Interpreter.Argument)params.get(i);
parameters.put(arg.name, parameters, arg.value);
}
flow.setParameters(parameters);
FOM_WebContinuation fom_wk = new FOM_WebContinuation(wk);
fom_wk.setParentScope(kScope);
fom_wk.setPrototype(ScriptableObject.getClassPrototype(kScope,
fom_wk.getClassName()));
initFlowVariables(kScope.getFlowVariables(), webctx);
Object[] args = new Object[] {k, fom_wk};
try {
ret = ScriptableObject.callMethod(flow,
"handleContinuation", args);
} catch (JavaScriptException ex) {
throw locationTracker.getException("Error calling continuation", ex);
} catch (EcmaError ee) {
throw locationTracker.getException("Error calling continuation", ee);
}
Object controller = kScope.get("controller", kScope);
if (controller != null && controller != Scriptable.NOT_FOUND) {
Map map = ConversionHelper.jsobjectToMap((Scriptable)controller);
webctx.getRequestScope().putAll(map);
}
} finally {
kScope.setLock(false);
setSessionScope(kScope, webctx);
if (flow != null) {
flow.popCallContext();
}
setFlash(webctx, null, kScope.getFlash());
cleanupFlowVariables(kScope.getFlowVariables());
Context.exit();
Thread.currentThread().setContextClassLoader(savedClassLoader);
}
return ret;
}
}