ovidiu      02/03/21 15:23:30

  Modified:    src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/javascript
                        JSCocoon.java
  Log:
  Added setter and getter for the ContinuationsManager.
  (jsFunction_processPipeline): Check if the pipeline was already executed.
  (jsFunction_lookupContinuation, jsFunction_diplayAllContinuations):
  New methods.
  
  Revision  Changes    Path
  1.4       +57 -1     
xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/javascript/JSCocoon.java
  
  Index: JSCocoon.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/javascript/JSCocoon.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JSCocoon.java     19 Mar 2002 09:38:21 -0000      1.3
  +++ JSCocoon.java     21 Mar 2002 23:23:30 -0000      1.4
  @@ -2,7 +2,11 @@
   
   import java.util.HashMap;
   import java.util.Map;
  +import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.cocoon.components.flow.AbstractInterpreter;
  +import org.apache.cocoon.components.flow.ContinuationsManager;
  +import org.apache.cocoon.components.flow.ContinuationsManagerImpl;
  +import org.apache.cocoon.components.flow.WebContinuation;
   import org.apache.cocoon.components.treeprocessor.InvokeContext;
   import org.apache.cocoon.environment.Context;
   import org.apache.cocoon.environment.Environment;
  @@ -14,6 +18,7 @@
   import org.mozilla.javascript.ScriptableObject;
   import org.mozilla.javascript.Wrapper;
   
  +
   /**
    * JavaScript interface to various Cocoon abstractions.
    *
  @@ -25,6 +30,9 @@
     protected AbstractInterpreter interp;
     protected Environment environment;
     protected InvokeContext context;
  +  protected ComponentManager manager;
  +  protected ContinuationsManager continuationsMgr;
  +  protected boolean responseSent = false;
   
     public JSCocoon() {}
   
  @@ -38,12 +46,24 @@
       this.interp = interp;
     }
   
  -  public void setContext(Environment environment, InvokeContext ctx)
  +  public void setContext(ComponentManager manager, Environment environment,
  +                         InvokeContext ctx)
     {
  +    this.manager = manager;
       this.environment = environment;
       this.context = ctx;
     }
   
  +  public void setContinuationsManager(ContinuationsManager mgr)
  +  {
  +    this.continuationsMgr = mgr;
  +  }
  +
  +  ContinuationsManager getContinuationsManager()
  +  {
  +    return continuationsMgr;
  +  }
  +
     public AbstractInterpreter jsGet_interpreter()
     {
       return interp;
  @@ -100,10 +120,22 @@
       return null;
     }
   
  +  public String jsFunction_toString()
  +  {
  +    return "[object " + toString() + "]";
  +  }
  +
     public void jsFunction_processPipeline(String name, Object pipelineArgs,
                                            Object bizData)
       throws Exception
     {
  +    if (responseSent) {
  +      System.out.println("Response was already sent!");
  +      return;
  +    }
  +    else
  +      responseSent = true;
  +    
       if (pipelineArgs instanceof Wrapper)
         pipelineArgs = ((Wrapper)pipelineArgs).unwrap();
       else if (pipelineArgs instanceof Scriptable)
  @@ -122,6 +154,30 @@
       finally {
         environment.removeAttribute("bean-dict");
       }
  +  }
  +
  +  public Scriptable jsFunction_lookupContinuation(String id)
  +    throws Exception
  +  {
  +    WebContinuation wk = continuationsMgr.lookupWebContinuation(id);
  +    JSWebContinuation jswk = null;
  +    if (wk != null)
  +      jswk = (JSWebContinuation)wk.getUserObject();
  +    return jswk;
  +  }
  +
  +  public void jsFunction_diplayAllContinuations()
  +  {
  +    if (continuationsMgr instanceof ContinuationsManagerImpl)
  +      ((ContinuationsManagerImpl)continuationsMgr).displayAllContinuations();
  +  }
  +
  +  // All right, this breaks the encapsulation, but I couldn't
  +  // find any better way to obtain the ComponentManager from a
  +  // JSWebContinuation.
  +  ComponentManager getComponentManager()
  +  {
  +    return manager;
     }
   
     public static Map jsobjectToMap(Scriptable jsobject)
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to