cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craft...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript JavaScriptInterpreter.java
Date Mon, 20 Jan 2003 20:37:00 GMT
crafterm    2003/01/20 12:36:59

  Modified:    src/java/org/apache/cocoon/components/flow/javascript
                        JavaScriptInterpreter.java
  Log:
  Applied enhancement that allows the Rhino debugger to use separate source
  windows when debugging a flow application that has more than one flow script,
  rather than one (large) source window with all the script combined.
  
  Submitted by: Christopher Oliver <res1cf5x@verizon.net>
  
  Revision  Changes    Path
  1.14      +25 -16    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JavaScriptInterpreter.java	9 Jan 2003 03:40:24 -0000	1.13
  +++ JavaScriptInterpreter.java	20 Jan 2003 20:36:59 -0000	1.14
  @@ -47,9 +47,11 @@
   
   import java.io.BufferedReader;
   import java.io.InputStreamReader;
  +import java.io.InputStream;
   import java.io.Reader;
   import java.util.ArrayList;
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -103,7 +105,7 @@
      */
     protected long lastTimeCheck = 0;
     JSGlobal scope;
  -  Script compiledScript;
  +  List compiledScripts = new ArrayList();
     JSErrorReporter errorReporter;
     boolean enableDebugger = false;
     org.mozilla.javascript.tools.debugger.Main debugger;
  @@ -184,7 +186,7 @@
         scope.put("log", scope, log);
       }
       catch (Exception e) {
  -      Context.exit();
  +      context.exit();
         e.printStackTrace();
         throw e;
       }
  @@ -317,8 +319,10 @@
         ((JSCocoon)cocoon).setScope(thrScope);
         thrScope.put("cocoon", thrScope, cocoon);
   
  -      if (compiledScript != null) {
  -        compiledScript.exec(context, thrScope);
  +      Iterator iter = compiledScripts.iterator();
  +      while (iter.hasNext()) {
  +      Script compiledScript = (Script)iter.next();
  +      compiledScript.exec(context, thrScope);
         }
       } else {
         cocoon = (JSCocoon)thrScope.get("cocoon", thrScope);
  @@ -340,10 +344,10 @@
     {
       JSCocoon cocoon = (JSCocoon)thrScope.get("cocoon", thrScope);
       cocoon.invalidateContext();
  -    Context.exit();
  +    Context.getCurrentContext().exit();
     }
   
  -  public void readScripts(Environment environment, ListInputStream is)
  +  public void readScripts(Environment environment, List sources)
       throws Exception
     {
       Scriptable thrScope = null;
  @@ -354,11 +358,17 @@
   
       try {
         thrScope = enterContext(environment);
  -      Reader reader = new BufferedReader(new InputStreamReader(is));
  -      Context context = Context.getCurrentContext();
  -
  -      compiledScript = context.compileReader(thrScope, reader,
  -                                         "(combined)", 1, null);
  +      Iterator iter = sources.iterator();
  +      while (iter.hasNext()) {
  +          Source src = (Source)iter.next();
  +          InputStream is = src.getInputStream();
  +          Reader reader = new BufferedReader(new InputStreamReader(is));
  +          Context context = Context.getCurrentContext();
  +          Script compiledScript = context.compileReader(thrScope, reader,
  +                                                        src.getSystemId(), 
  +                                                        1, null);
  +          compiledScripts.add(compiledScript);
  +      }
       }
       catch (Exception ex) {
         ex.printStackTrace();
  @@ -425,10 +435,9 @@
           scripts.add(src);
         }
         needResolve.clear();
  -
  -      ListInputStream is = new ListInputStream(scripts);
  -      errorReporter = new JSErrorReporter(is.getSourceInfo());
  -      readScripts(environment, is);
  +      //ListInputStream is = new ListInputStream(scripts);
  +      //errorReporter = new JSErrorReporter(is.getSourceInfo());
  +      readScripts(environment, scripts);
       }
   
       // Update the time of the last check. If an exception occurs, this
  @@ -574,7 +583,7 @@
         throw ex;
       }
       finally {
  -      Context.exit();
  +      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