cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ovi...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow JavaScriptInterpreter.java
Date Mon, 25 Mar 2002 07:33:54 GMT
ovidiu      02/03/24 23:33:54

  Modified:    src/scratchpad/schecoon/src/org/apache/cocoon/components/flow
                        JavaScriptInterpreter.java
  Log:
  Save the Rhino scope in the JSCocoon created object. Invalidate the
  Environment and InvokeContext objects in the JSCocoon instance,
  instead of removing JSCocoon from the scope.
  
  (handleContinuation): Added. Make use of the Rhino scope saved in
  JSCocoon to resume the processing.
  
  Revision  Changes    Path
  1.10      +40 -2     xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/JavaScriptInterpreter.java
  
  Index: JavaScriptInterpreter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/JavaScriptInterpreter.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JavaScriptInterpreter.java	24 Mar 2002 07:37:27 -0000	1.9
  +++ JavaScriptInterpreter.java	25 Mar 2002 07:33:54 -0000	1.10
  @@ -101,6 +101,7 @@
       ((JSCocoon)cocoon).setInterpreter(this);
       ((JSCocoon)cocoon).setContext(manager, environment, ctx);
       ((JSCocoon)cocoon).setContinuationsManager(continuationsMgr);
  +    ((JSCocoon)cocoon).setScope(thrScope);
       thrScope.put("cocoon", thrScope, cocoon);
   
       return thrScope;
  @@ -113,8 +114,8 @@
      */
     protected void exitContext(Scriptable thrScope)
     {
  -    if (thrScope != null)
  -      thrScope.delete("cocoon");
  +    JSCocoon cocoon = (JSCocoon)thrScope.get("cocoon", thrScope);
  +    cocoon.invalidateContext();
       Context.getCurrentContext().exit();
     }
   
  @@ -183,6 +184,43 @@
       }
       finally {
         exitContext(thrScope);
  +    }
  +  }
  +
  +  public void handleContinuation(String id,
  +                          Environment environment, InvokeContext ctx)
  +    throws Exception
  +  {
  +    WebContinuation wk = continuationsMgr.lookupWebContinuation(id);
  +
  +    if (wk == null)
  +      throw new RuntimeException("No continuation with id " + id);
  +
  +    Context context = Context.enter();
  +    context.setOptimizationLevel(OPTIMIZATION_LEVEL);
  +    context.setCompileFunctionsWithDynamicScope(true);
  +
  +    // Obtain the JS continuation object from it, and setup the
  +    // JSCocoon object associated in the dynamic scope of the saved
  +    // continuation with the environment and context objects.
  +    JSWebContinuation jswk = (JSWebContinuation)wk.getUserObject();
  +    JSCocoon cocoon = jswk.getJSCocoon();
  +    cocoon.setContext(manager, environment, ctx);
  +    Scriptable kScope = cocoon.getScope();
  +
  +    // We can now resume the processing from the state saved by the
  +    // continuation object. Setup the JavaScript Context object.
  +    Object handleContFunction = scope.get("handleContinuation", kScope);
  +    if (handleContFunction == Scriptable.NOT_FOUND)
  +      throw new RuntimeException("Cannot find 'handleContinuation' "
  +                                 + "(system.js not loaded?)");
  +
  +    Object args[] = { jswk };
  +    try {
  +      ((Function)handleContFunction).call(context, kScope, kScope, args);
  +    }
  +    finally {
  +      context.exit();
       }
     }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message