orlikowski    2003/07/07 19:56:50

  Modified:    src/org/apache/bsf BSFEngine.java BSFManager.java Main.java
               src/org/apache/bsf/engines/jacl JaclEngine.java
               src/org/apache/bsf/engines/java JavaEngine.java
               src/org/apache/bsf/engines/javaclass JavaClassEngine.java
               src/org/apache/bsf/engines/javascript JavaScriptEngine.java
               src/org/apache/bsf/engines/jpython JPythonEngine.java
               src/org/apache/bsf/engines/jython JythonEngine.java
               src/org/apache/bsf/engines/netrexx NetRexxEngine.java
               src/org/apache/bsf/engines/xslt XSLTEngine.java
               src/org/apache/bsf/util BSFEngineImpl.java
                        BSFEventProcessor.java BSFFunctions.java
                        EngineUtils.java
  Log:
  Debated this for a bit, but decided that I wouldn't influence future
  debug designs with these leftover bones.
  
  This removes the last of the old debug layer (i.e. parameters to functions
  that were used for debugging).
  
  Revision  Changes    Path
  1.2       +25 -71    jakarta-bsf/src/org/apache/bsf/BSFEngine.java
  
  Index: BSFEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/BSFEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BSFEngine.java    25 Jun 2003 09:14:17 -0000      1.1
  +++ BSFEngine.java    8 Jul 2003 02:56:49 -0000       1.2
  @@ -61,8 +61,8 @@
   import org.apache.bsf.util.CodeBuffer;
   
   /**
  - * This is the view of a scripting engine assumed by the bean scripting
  - * framework. This interface is used when an application decides to
  + * This is the view of a scripting engine assumed by the Bean Scripting
  + * Framework. This interface is used when an application decides to
    * run some script under application control. (This is the reverse of
    * the more common situation, which is that of the scripting language
    * calling into the application.)
  @@ -84,37 +84,28 @@
   public interface BSFEngine extends PropertyChangeListener {
        
        /**
  -      * This is used by an application to invoke an anonymous function. An
  -      * anonymous function is a multi-line script which when evaluated will
  +      * This is used by an application to invoke an anonymous function. 
  +     * An anonymous function is a multi-line script which when evaluated will
         * produce a value. These are separated from expressions and scripts
         * because the prior are spsed to be good 'ol expressions and scripts
         * are not value returning. We allow anonymous functions to have parameters
         * as well for completeness.
         *
  -      * @param source   (context info) the source of this expression
  -      *                 (e.g., filename)
  -      * @param lineNo   (context info) the line number in source for expr
  -      * @param columnNo (context info) the column number in source for expr
         * @param funcBody the multi-line, value returning script to evaluate
         * @param paramNames the names of the parameters above assumes
         * @param arguments values of the above parameters
         *
         * @exception BSFException if anything goes wrong while doin' it.
         */
  -     public Object apply(
  -             String source,
  -             int lineNo,
  -             int columnNo,
  -             Object funcBody,
  -             Vector paramNames,
  -             Vector arguments)
  +     public Object apply(Object funcBody, Vector paramNames, Vector arguments)
                throws BSFException;
        /**
         * This is used by an application to call into the scripting engine
  -      * to make a function/method call. The "object" argument is the object
  -      * whose method is to be called, if that applies. For non-OO languages,
  -      * this is typically ignored and should be given as null. For pretend-OO
  -      * languages such as VB, this would be the (String) name of the object.
  +      * to make a function/method call.
  +     * The "object" argument is the object whose method is to be called, 
  +     * if that applies. For non-OO languages, this is typically ignored 
  +     * and should be given as null. For pretend-OO languages such as VB,
  +     * this would be the (String) name of the object.
         * The arguments are given in the args array.
         *
         * @param object object on which to make the call
  @@ -127,13 +118,9 @@
        public Object call(Object object, String name, Object[] args)
                throws BSFException;
        /**
  -      * This is used by an application to compile an anonymous function. See
  -      * comments in apply for more hdetails.
  +      * This is used by an application to compile an anonymous function. 
  +     * See comments in apply() for more details.
         *
  -      * @param source   (context info) the source of this expression
  -      *                 (e.g., filename)
  -      * @param lineNo   (context info) the line number in source for expr
  -      * @param columnNo (context info) the column number in source for expr
         * @param funcBody the multi-line, value returning script to evaluate
         * @param paramNames the names of the parameters above assumes
         * @param arguments values of the above parameters
  @@ -142,9 +129,6 @@
         * @exception BSFException if anything goes wrong while doin' it.
         */
        public void compileApply(
  -             String source,
  -             int lineNo,
  -             int columnNo,
                Object funcBody,
                Vector paramNames,
                Vector arguments,
  @@ -155,48 +139,30 @@
         * The expr may be string or some other type, depending on the language.
         * The generated code is dumped into the <tt>CodeBuffer</tt>.
         *
  -      * @param source   (context info) the source of this expression
  -      *                 (e.g., filename)
  -      * @param lineNo   (context info) the line number in source for expr
  -      * @param columnNo (context info) the column number in source for expr
         * @param expr     the expression to compile
         * @param cb       the CodeBuffer to compile into
         *
         * @exception BSFException if anything goes wrong while compiling a
         *            BSFException is thrown. The reason indicates the problem.
         */
  -     public void compileExpr(
  -             String source,
  -             int lineNo,
  -             int columnNo,
  -             Object expr,
  -             CodeBuffer cb)
  +     public void compileExpr(Object expr, CodeBuffer cb)
                throws BSFException;
        /**
  -      * This is used by an application to compile some script. The
  -      * script may be string or some other type, depending on the
  +      * This is used by an application to compile some script. 
  +     * The script may be string or some other type, depending on the
         * language. The generated code is dumped into the <tt>CodeBuffer</tt>.
         *
  -      * @param source   (context info) the source of this script
  -      *                 (e.g., filename)
  -      * @param lineNo   (context info) the line number in source for script
  -      * @param columnNo (context info) the column number in source for script
         * @param script   the script to compile
         * @param cb       the CodeBuffer to compile into
         *
         * @exception BSFException if anything goes wrong while compiling a
         *            BSFException is thrown. The reason indicates the problem.
         */
  -     public void compileScript(
  -             String source,
  -             int lineNo,
  -             int columnNo,
  -             Object script,
  -             CodeBuffer cb)
  +     public void compileScript(Object script, CodeBuffer cb)
                throws BSFException;
        /**
  -      * Declare a bean after the engine has been started. Declared beans
  -      * are beans that are named and which the engine must make available
  +      * Declare a bean after the engine has been started.
  +     * Declared beans are beans that are named and which the engine must make 
available
         * to the scripts it runs in the most first class way possible.
         *
         * @param bean the bean to declare
  @@ -205,39 +171,29 @@
         */
        public void declareBean(BSFDeclaredBean bean) throws BSFException;
        /**
  -      * This is used by an application to evaluate an expression. The
  -      * expression may be string or some other type, depending on the
  +      * This is used by an application to evaluate an expression.
  +     * The expression may be string or some other type, depending on the
         * language. (For example, for BML it'll be an org.w3c.dom.Element
         * object.)
         *
  -      * @param source   (context info) the source of this expression
  -      *                 (e.g., filename)
  -      * @param lineNo   (context info) the line number in source for expr
  -      * @param columnNo (context info) the column number in source for expr
         * @param expr     the expression to evaluate
         *
         * @exception BSFException if anything goes wrong while eval'ing a
         *            BSFException is thrown. The reason indicates the problem.
         */
  -     public Object eval(String source, int lineNo, int columnNo, Object expr)
  -             throws BSFException;
  +     public Object eval(Object expr) throws BSFException;
        /**
  -      * This is used by an application to execute some script. The
  -      * expression may be string or some other type, depending on the
  +      * This is used by an application to execute some script.
  +     * The expression may be string or some other type, depending on the
         * language. Returns nothing but if something goes wrong it excepts
         * (of course).
         *
  -      * @param source   (context info) the source of this expression
  -      *                 (e.g., filename)
  -      * @param lineNo   (context info) the line number in source for expr
  -      * @param columnNo (context info) the column number in source for expr
         * @param script   the script to execute
         *
         * @exception BSFException if anything goes wrong while exec'ing a
         *            BSFException is thrown. The reason indicates the problem.
         */
  -     public void exec(String source, int lineNo, int columnNo, Object script)
  -             throws BSFException;
  +     public void exec(Object script) throws BSFException;
       /**
        * This is used by an application to execute some script, as though
        * one were interacting with the language in an interactive session. 
  @@ -254,9 +210,7 @@
        * @exception BSFException if anything goes wrong while exec'ing a
        *            BSFException is thrown. The reason indicates the problem.
        */
  -    public void iexec(String source, int lineNo, int columnNo, Object script)
  -        throws BSFException;
  -
  +    public void iexec(Object script) throws BSFException;
        /**
         * This method is used to initialize the engine right after construction.
         * This method will be called before any calls to eval or call. At this
  
  
  
  1.2       +28 -97    jakarta-bsf/src/org/apache/bsf/BSFManager.java
  
  Index: BSFManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/BSFManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BSFManager.java   25 Jun 2003 09:14:17 -0000      1.1
  +++ BSFManager.java   8 Jul 2003 02:56:49 -0000       1.2
  @@ -167,27 +167,17 @@
        * parameters and return the resulting value.
        *
        * @param lang language identifier
  -     * @param source (context info) the source of this expression
  -     (e.g., filename)
  -     * @param lineNo (context info) the line number in source for expr
  -     * @param columnNo (context info) the column number in source for expr
        * @param funcBody the multi-line, value returning script to evaluate
        * @param paramNames the names of the parameters above assumes
        * @param arguments values of the above parameters
        *
        * @exception BSFException if anything goes wrong while running the script
        */
  -    public Object apply(String lang,
  -                        String source,
  -                        int lineNo,
  -                        int columnNo,
  -                        Object funcBody,
  -                        Vector paramNames,
  +    public Object apply(String lang, Object funcBody, Vector paramNames,
                           Vector arguments)
           throws BSFException {
  +
           final BSFEngine e = loadScriptingEngine(lang);
  -        final String sourcef = source;
  -        final int lineNof = lineNo, columnNof = columnNo;
           final Object funcBodyf = funcBody;
           final Vector paramNamesf = paramNames;
           final Vector argumentsf = arguments;
  @@ -197,8 +187,7 @@
               final Object resultf = 
                   AccessController.doPrivileged(new PrivilegedExceptionAction() {
                           public Object run() throws Exception {
  -                            return e.apply(sourcef, lineNof, columnNof, 
  -                                           funcBodyf, paramNamesf, argumentsf);
  +                            return e.apply(funcBodyf, paramNamesf, argumentsf);
                           }
                       });
               result = resultf;
  @@ -215,10 +204,6 @@
        * language to the given parameters into the given <tt>CodeBuffer</tt>.
        *
        * @param lang language identifier
  -     * @param source (context info) the source of this expression
  -     (e.g., filename)
  -     * @param lineNo (context info) the line number in source for expr
  -     * @param columnNo (context info) the column number in source for expr
        * @param funcBody the multi-line, value returning script to evaluate
        * @param paramNames the names of the parameters above assumes
        * @param arguments values of the above parameters
  @@ -226,18 +211,11 @@
        *
        * @exception BSFException if anything goes wrong while running the script
        */
  -    public void compileApply(String lang,
  -                             String source,
  -                             int lineNo,
  -                             int columnNo,
  -                             Object funcBody,
  -                             Vector paramNames,
  -                             Vector arguments,
  -                             CodeBuffer cb)
  +    public void compileApply(String lang, Object funcBody, Vector paramNames,
  +                             Vector arguments, CodeBuffer cb)
           throws BSFException {
  +
           final BSFEngine e = loadScriptingEngine(lang);
  -        final String sourcef = source;
  -        final int lineNof = lineNo, columnNof = columnNo;
           final Object funcBodyf = funcBody;
           final Vector paramNamesf = paramNames;
           final Vector argumentsf = arguments;
  @@ -246,8 +224,7 @@
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
                       public Object run() throws Exception {
  -                        e.compileApply(sourcef, lineNof, columnNof, 
  -                                       funcBodyf, paramNamesf, 
  +                        e.compileApply(funcBodyf, paramNamesf, 
                                          argumentsf, cbf);
                           return null;
                       }
  @@ -263,32 +240,22 @@
        * <tt>CodeBuffer</tt>.
        *
        * @param lang     language identifier
  -     * @param source   (context info) the source of this expression
  -     (e.g., filename)
  -     * @param lineNo   (context info) the line number in source for expr
  -     * @param columnNo (context info) the column number in source for expr
        * @param expr     the expression to compile
        * @param cb       code buffer to compile into
        *
        * @exception BSFException if any error while compiling the expression
        */
  -    public void compileExpr(String lang,
  -                            String source,
  -                            int lineNo,
  -                            int columnNo,
  -                            Object expr,
  -                            CodeBuffer cb)
  +    public void compileExpr(String lang, Object expr, CodeBuffer cb)
           throws BSFException {
  +
           final BSFEngine e = loadScriptingEngine(lang);
  -        final String sourcef = source;
  -        final int lineNof = lineNo, columnNof = columnNo;
           final Object exprf = expr;
           final CodeBuffer cbf = cb;
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
                       public Object run() throws Exception {
  -                        e.compileExpr(sourcef, lineNof, columnNof, exprf, cbf);
  +                        e.compileExpr(exprf, cbf);
                           return null;
                       }
                   });
  @@ -303,33 +270,22 @@
        * <tt>CodeBuffer</tt>.
        *
        * @param lang     language identifier
  -     * @param source   (context info) the source of this script
  -     (e.g., filename)
  -     * @param lineNo   (context info) the line number in source for script
  -     * @param columnNo (context info) the column number in source for script
        * @param script   the script to compile
        * @param cb       code buffer to compile into
        *
        * @exception BSFException if any error while compiling the script
        */
  -    public void compileScript(String lang,
  -                              String source,
  -                              int lineNo,
  -                              int columnNo,
  -                              Object script,
  -                              CodeBuffer cb)
  +    public void compileScript(String lang, Object script, CodeBuffer cb)
           throws BSFException {
  +
           final BSFEngine e = loadScriptingEngine(lang);
  -        final String sourcef = source;
  -        final int lineNof = lineNo, columnNof = columnNo;
           final Object scriptf = script;
           final CodeBuffer cbf = cb;
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
                       public Object run() throws Exception {
  -                        e.compileScript(sourcef, lineNof, columnNof, 
  -                                        scriptf, cbf);
  +                        e.compileScript(scriptf, cbf);
                           return null;
                       }
                   });
  @@ -371,6 +327,7 @@
        */
       public void declareBean(String beanName, Object bean, Class type)
           throws BSFException {
  +        
           registerBean(beanName, bean);
   
           BSFDeclaredBean tempBean = new BSFDeclaredBean(beanName, bean, type);
  @@ -389,23 +346,14 @@
        * resulting value.
        *
        * @param lang language identifier
  -     * @param source (context info) the source of this expression
  -     (e.g., filename)
  -     * @param lineNo (context info) the line number in source for expr
  -     * @param columnNo (context info) the column number in source for expr
        * @param expr the expression to evaluate
        *
        * @exception BSFException if anything goes wrong while running the script
        */
  -    public Object eval(String lang,
  -                       String source,
  -                       int lineNo,
  -                       int columnNo,
  -                       Object expr)
  +    public Object eval(String lang, Object expr)
           throws BSFException {
  +
           final BSFEngine e = loadScriptingEngine(lang);
  -        final String sourcef = source;
  -        final int lineNof = lineNo, columnNof = columnNo;
           final Object exprf = expr;
           Object result = null;
           
  @@ -413,7 +361,7 @@
               final Object resultf =
                   AccessController.doPrivileged(new PrivilegedExceptionAction() {
                           public Object run() throws Exception {
  -                            return e.eval(sourcef, lineNof, columnNof, exprf);
  +                            return e.eval(exprf);
                           }
                       });
               result = resultf;
  @@ -436,29 +384,20 @@
        * Execute the given script of the given language.
        *
        * @param lang     language identifier
  -     * @param source   (context info) the source of this expression
  -     (e.g., filename)
  -     * @param lineNo   (context info) the line number in source for expr
  -     * @param columnNo (context info) the column number in source for expr
        * @param script   the script to execute
        *
        * @exception BSFException if anything goes wrong while running the script
        */
  -    public void exec(String lang,
  -                     String source,
  -                     int lineNo,
  -                     int columnNo,
  -                     Object script)
  +    public void exec(String lang, Object script)
           throws BSFException {
  +
           final BSFEngine e = loadScriptingEngine(lang);
  -        final String sourcef = source;
  -        final int lineNof = lineNo, columnNof = columnNo;
           final Object scriptf = script;
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
                       public Object run() throws Exception {
  -                        e.exec(sourcef, lineNof, columnNof, scriptf);
  +                        e.exec(scriptf);
                           return null;
                       }
                   });
  @@ -473,29 +412,20 @@
        * emulate an interactive session w/ the language.
        *
        * @param lang     language identifier
  -     * @param source   (context info) the source of this expression 
  -     *                 (e.g., filename)
  -     * @param lineNo   (context info) the line number in source for expr
  -     * @param columnNo (context info) the column number in source for expr
        * @param script   the script to execute
        *
        * @exception BSFException if anything goes wrong while running the script
        */
  -    public void iexec(String lang,
  -                     String source,
  -                     int lineNo,
  -                     int columnNo,
  -                     Object script)
  +    public void iexec(String lang, Object script)
           throws BSFException {
  +
           final BSFEngine e = loadScriptingEngine(lang);
  -        final String sourcef = source;
  -        final int lineNof = lineNo, columnNof = columnNo;
           final Object scriptf = script;
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
                       public Object run() throws Exception {
  -                        e.iexec(sourcef, lineNof, columnNof, scriptf);
  +                        e.iexec(scriptf);
                           return null;
                       }
                   });
  @@ -541,6 +471,7 @@
        */
       public static String getLangFromFilename(String fileName) 
           throws BSFException {
  +
           int dotIndex = fileName.lastIndexOf(".");
   
           if (dotIndex != -1) {
  @@ -631,21 +562,21 @@
        *            exception is passed on as well.
        */
       public BSFEngine loadScriptingEngine(String lang) throws BSFException {
  -        // if its already loaded return that
  +        // If already loaded, return it 
           BSFEngine eng = (BSFEngine) loadedEngines.get(lang);
           if (eng != null) {
               return eng;
           }
   
  -        // is it a registered language?
  +        // Is it a registered language?
           String engineClassName = (String) registeredEngines.get(lang);
           if (engineClassName == null) {
               throw new BSFException(BSFException.REASON_UNKNOWN_LANGUAGE,
                                      "unsupported language: " + lang);
           }
   
  -        // create the engine and initialize it. if anything goes wrong
  -        // except.
  +        // Create the engine and initialize it. Throw exception in case
  +        // of failure.
           try {
               Class engineClass =
                   (classLoader == null)
  
  
  
  1.2       +2 -5      jakarta-bsf/src/org/apache/bsf/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/Main.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Main.java 25 Jun 2003 09:14:17 -0000      1.1
  +++ Main.java 8 Jul 2003 02:56:49 -0000       1.2
  @@ -140,19 +140,16 @@
                                cb.setClassName(outClassName);
                                mgr.compileScript(
                                        language,
  -                                     inFileName,
  -                                     0,
  -                                     0,
                                        IOUtils.getStringFromReader(in),
                                        cb);
                                cb.print(pw, true);
                                out.close();
                        } else
                                if (mode.equals(ARG_VAL_EXEC)) {
  -                                     mgr.exec(language, inFileName, 0, 0, 
IOUtils.getStringFromReader(in));
  +                                     mgr.exec(language, 
IOUtils.getStringFromReader(in));
                                } else /* eval */ {
                                        Object obj =
  -                                            mgr.eval(language, inFileName, 0, 0, 
IOUtils.getStringFromReader(in));
  +                                            mgr.eval(language, 
IOUtils.getStringFromReader(in));
                                           
                                        // Try to display the result.
                                           
  
  
  
  1.2       +1 -2      jakarta-bsf/src/org/apache/bsf/engines/jacl/JaclEngine.java
  
  Index: JaclEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/engines/jacl/JaclEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JaclEngine.java   25 Jun 2003 09:14:20 -0000      1.1
  +++ JaclEngine.java   8 Jul 2003 02:56:49 -0000       1.2
  @@ -105,8 +105,7 @@
      * This is used by an application to evaluate a string containing
      * some expression.
      */
  -  public Object eval (String source, int lineNo, int columnNo, 
  -                   Object oscript) throws BSFException {
  +  public Object eval (Object oscript) throws BSFException {
        String script = oscript.toString ();
        try {
          interp.eval (script);
  
  
  
  1.2       +2 -4      jakarta-bsf/src/org/apache/bsf/engines/java/JavaEngine.java
  
  Index: JavaEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/engines/java/JavaEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JavaEngine.java   25 Jun 2003 09:14:21 -0000      1.1
  +++ JavaEngine.java   8 Jul 2003 02:56:50 -0000       1.2
  @@ -155,8 +155,7 @@
        throw new BSFException (BSFException.REASON_UNSUPPORTED_FEATURE,
                            "call() is not currently supported by JavaEngine");
     }
  -  public void compileScript (String source, int lineNo, int columnNo,
  -               Object script, CodeBuffer cb) throws BSFException {
  +  public void compileScript (Object script, CodeBuffer cb) throws BSFException {
        ObjInfo oldRet = cb.getFinalServiceMethodStatement ();
   
        if (oldRet != null && oldRet.isExecutable ()) {
  @@ -183,8 +182,7 @@
      * We will attempt to use it, then if necessary fall back on invoking
      * javac via the command line.
      */
  -  public Object eval (String source, int lineNo, int columnNo, 
  -                   Object oscript) throws BSFException
  +  public Object eval (Object oscript) throws BSFException
     {
        if (debug)
        {
  
  
  
  1.2       +1 -2      
jakarta-bsf/src/org/apache/bsf/engines/javaclass/JavaClassEngine.java
  
  Index: JavaClassEngine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-bsf/src/org/apache/bsf/engines/javaclass/JavaClassEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JavaClassEngine.java      25 Jun 2003 09:14:21 -0000      1.1
  +++ JavaClassEngine.java      8 Jul 2003 02:56:50 -0000       1.2
  @@ -105,8 +105,7 @@
      * This is used by an application to evaluate an object containing
      * some expression - clearly not possible for compiled code ..
      */
  -  public Object eval (String source, int lineNo, int columnNo, 
  -                   Object oscript) throws BSFException {
  +  public Object eval (Object oscript) throws BSFException {
        throw new BSFException (BSFException.REASON_UNSUPPORTED_FEATURE,
                            "Java bytecode engine can't evaluate expressions");
     }
  
  
  
  1.4       +2 -4      
jakarta-bsf/src/org/apache/bsf/engines/javascript/JavaScriptEngine.java
  
  Index: JavaScriptEngine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-bsf/src/org/apache/bsf/engines/javascript/JavaScriptEngine.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JavaScriptEngine.java     3 Jul 2003 16:01:26 -0000       1.3
  +++ JavaScriptEngine.java     8 Jul 2003 02:56:50 -0000       1.4
  @@ -155,12 +155,11 @@
        * This is used by an application to evaluate a string containing
        * some expression.
        */
  -    public Object eval(String source, int lineNo, int columnNo, Object oscript)
  +    public Object eval(Object oscript)
           throws BSFException {
   
           String scriptText = oscript.toString();
           Object retval = null;
  -        Script script;
           Context cx;
   
           try {
  @@ -173,8 +172,7 @@
               cx.setDebugger(null, null);
   
               retval = cx.evaluateString(global, scriptText,
  -                                       source, lineNo,
  -                                       null);
  +                                       null, -1, null);
   
               if (retval instanceof NativeJavaObject)
                   retval = ((NativeJavaObject) retval).unwrap();
  
  
  
  1.2       +2 -4      
jakarta-bsf/src/org/apache/bsf/engines/jpython/JPythonEngine.java
  
  Index: JPythonEngine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-bsf/src/org/apache/bsf/engines/jpython/JPythonEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JPythonEngine.java        25 Jun 2003 09:14:21 -0000      1.1
  +++ JPythonEngine.java        8 Jul 2003 02:56:50 -0000       1.2
  @@ -108,8 +108,7 @@
     /**
      * Evaluate an expression.
      */
  -  public Object eval (String source, int lineNo, int columnNo, 
  -                   Object script) throws BSFException {
  +  public Object eval (Object script) throws BSFException {
        try {
          Object result = interp.eval (script.toString ());
          if (result != null && result instanceof PyJavaInstance)
  @@ -123,8 +122,7 @@
     /**
      * Execute a script. 
      */
  -  public void exec (String source, int lineNo, int columnNo,
  -                 Object script) throws BSFException {
  +  public void exec (Object script) throws BSFException {
        try {
          interp.exec (script.toString ());
        } catch (PyException e) {
  
  
  
  1.2       +4 -8      jakarta-bsf/src/org/apache/bsf/engines/jython/JythonEngine.java
  
  Index: JythonEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/engines/jython/JythonEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JythonEngine.java 25 Jun 2003 09:14:21 -0000      1.1
  +++ JythonEngine.java 8 Jul 2003 02:56:50 -0000       1.2
  @@ -113,8 +113,7 @@
      * Evaluate an anonymous function (differs from eval() in that apply() 
      * handles multiple lines).
      */
  -  public Object apply (String source, int lineNo, int columnNo, 
  -                       Object funcBody, Vector paramNames,
  +  public Object apply (Object funcBody, Vector paramNames,
                          Vector arguments) throws BSFException {
         try {
             /* We wrapper the original script in a function definition, and
  @@ -148,8 +147,7 @@
     /**
      * Evaluate an expression.
      */
  -  public Object eval (String source, int lineNo, int columnNo, 
  -                   Object script) throws BSFException {
  +  public Object eval (Object script) throws BSFException {
        try {
          Object result = interp.eval (script.toString ());
          if (result != null && result instanceof PyJavaInstance)
  @@ -164,8 +162,7 @@
     /**
      * Execute a script. 
      */
  -  public void exec (String source, int lineNo, int columnNo,
  -                 Object script) throws BSFException {
  +  public void exec (Object script) throws BSFException {
        try {
          interp.exec (script.toString ());
        } catch (PyException e) {
  @@ -177,8 +174,7 @@
     /**
      * Execute script code, emulating console interaction.
      */
  -  public void iexec (String source, int lineNo, int columnNo,
  -                     Object script) throws BSFException {
  +  public void iexec (Object script) throws BSFException {
         try {
             if (interp.buffer.length() > 0)
                 interp.buffer.append("\n");
  
  
  
  1.2       +407 -407  
jakarta-bsf/src/org/apache/bsf/engines/netrexx/NetRexxEngine.java
  
  Index: NetRexxEngine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-bsf/src/org/apache/bsf/engines/netrexx/NetRexxEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NetRexxEngine.java        25 Jun 2003 09:14:21 -0000      1.1
  +++ NetRexxEngine.java        8 Jul 2003 02:56:50 -0000       1.2
  @@ -107,417 +107,417 @@
    * @author  Joe Kesselman
    * @author  Sanjiva Weerawarana
    */
  -public class NetRexxEngine extends BSFEngineImpl
  -{
  -     BSFFunctions mgrfuncs;
  -     private boolean bsfHandleCreated = false;
  -     static Hashtable codeToClass=new Hashtable();
  -     static String serializeCompilation="";
  -     static String placeholder="$$CLASSNAME$$";
  -     String minorPrefix;
  -  
  -     /**
  -      * Create a scratchfile, open it for writing, return its name.
  -      * Relies on the filesystem to provide us with uniqueness testing.
  -      * NOTE THAT uniqueFileOffset continues to count; we don't want to
  -      * risk reusing a classname we have previously loaded in this session
  -      * even if the classfile has been deleted.
  -      *
  -      * I've made the offset static, due to concerns about reuse/reentrancy
  -      * of the NetRexx engine.
  -      */
  -  private static int uniqueFileOffset=0;
  -  private class GeneratedFile 
  -  {
  -     File file=null;
  -     FileOutputStream fos=null;
  -     String className=null;
  -     GeneratedFile(File file,FileOutputStream fos,String className) 
  -       {
  -               this.file=file;
  -               this.fos=fos;
  -               this.className=className;
  -       }
  -  }
  -     
  -     // rexxclass used to be an instance variable, on the theory that
  -     // each NetRexxEngine was an instance of a specific script.
  -     // BSF is currently reusing Engines, so caching the class
  -     // no longer makes sense.
  -     // Class rexxclass;
  -     
  -     /**
  -      * Constructor.
  -      */
  -     public NetRexxEngine ()
  -     {
  -             /*
  -               The following line is intended to cause the constructor to
  -               throw a NoClassDefFoundError if the NetRexxC.zip dependency
  -               is not resolved.
  -               
  -               If this line was not here, the problem would not surface until
  -               the actual processing of a script. We want to know all is well
  -               at the time the engine is instantiated, not when we attempt to
  -               process a script.
  -               */
  -             
  -             new netrexx.lang.BadArgumentException();
  -     }
  -     /**
  -      * Return an object from an extension.
  -      * @param Object object from which to call our static method
  -      * @param method The name of the method to call.
  -      * @param args an array of arguments to be
  -      * passed to the extension, which may be either
  -      * Vectors of Nodes, or Strings.
  -      */
  -     public Object call (Object object,String method, Object[] args) 
  -     throws BSFException
  -     {
  -             throw new BSFException(BSFException.REASON_UNSUPPORTED_FEATURE,
  -                                                        "NetRexx doesn't currently 
support call()",
  -                                                        null);
  -     }
  -     /**
  -      * Invoke a static method.
  -      * @param rexxclass Class to invoke the method against
  -      * @param method The name of the method to call.
  -      * @param args an array of arguments to be
  -      * passed to the extension, which may be either
  -      * Vectors of Nodes, or Strings.
  -      */
  -     Object callStatic(Class rexxclass, String method, Object[] args) 
  -     throws BSFException
  -     {
  -             //***** ISSUE: Currently supports only static methods
  -             Object retval = null;
  -             try
  -             {
  -                     if (rexxclass != null)
  -                     {
  -                             //***** This should call the lookup used in BML, for 
typesafety
  -                             Class[] argtypes=new Class[args.length];
  -                             for(int i=0;i<args.length;++i)
  -                                     argtypes[i]=args[i].getClass();
  -                             
  -                             Method m=MethodUtils.getMethod(rexxclass, method, 
argtypes);
  -                             retval=m.invoke(null,args);
  -                     }
  -                     else
  -                     {
  -                             DebugLog.stderrPrintln ("NetRexxEngine: ERROR: 
rexxclass==null!", DebugLog.BSF_LOG_L3);
  -                     }
  -             }
  -             catch(Exception e)
  -             {
  -                     e.printStackTrace ();
  -                     if (e instanceof InvocationTargetException)
  -                     {
  -                             Throwable t = 
((InvocationTargetException)e).getTargetException ();
  -                             t.printStackTrace ();
  -                     }
  -                     throw new BSFException (BSFException.REASON_IO_ERROR,
  -                                                                     e.getMessage 
(),
  -                                                                     e);
  -             }
  -             return retval;
  -     }
  -     public void declareBean (BSFDeclaredBean bean) throws BSFException {}
  -     /**
  -      * Override impl of execute. In NetRexx, methods which do not wish
  -      * to return a value should be invoked via exec, which will cause them
  -      * to be generated without the "returns" clause.
  -      * Those which wish to return a value should call eval instead.
  -      * which will add "returns java.lang.Object" to the header.
  -      *
  -      * Note: It would be nice to have the "real" return type avaialable, so
  -      * we could do something more type-safe than Object, and so we could
  -      * return primitive types without having to enclose them in their
  -      * object wrappers. BSF does not currently support that concept.
  -      */
  -     public Object eval (String source, int lineNo, int columnNo,
  -                                     Object script)
  -     throws BSFException
  -     {
  -             return execEvalShared(source, lineNo, columnNo, script,true);
  -     }
  -     /**
  -      * Override impl of execute. In NetRexx, methods which do not wish
  -      * to return a value should be invoked via exec, which will cause them
  -      * to be generated without the "returns" clause.
  -      * Those which wish to return a value should call eval instead.
  -      * which will add "returns java.lang.Object" to the header.
  -      */
  -     public void exec (String source, int lineNo, int columnNo,
  -                               Object script)
  -     throws BSFException
  -     {
  -              execEvalShared(source, lineNo, columnNo, script,false);
  -     }
  -     /**
  -      * This is shared code for the exec() and eval() operations. It will
  -      * evaluate a string containing a NetRexx method body -- which may be
  -      * as simple as a single return statement.
  -      * It should store the "bsf" handle where the
  -      * script can get to it, for callback purposes.
  -      * <p>
  -      * Note that NetRexx compilation imposes serious overhead -- 11 seconds for
  -      * the first compile, about 3 thereafter -- but in exchange you get
  -      * Java-like speeds once the classes have been created (minus the cache
  -      * lookup cost).
  -      * <p>
  -      * Nobody knows whether javac is threadsafe.
  -      * I'm going to serialize access to the compilers to protect it.
  -      */
  -     public Object execEvalShared (String source, int lineNo, int columnNo, 
  -                                                       Object oscript,boolean 
returnsObject)
  -     throws BSFException
  -     {
  -             Object retval=null;
  -             String classname=null;
  -             GeneratedFile gf=null;
  -             
  -             // Moved into the exec process; see comment above.
  -             Class rexxclass=null;
  -             
  -             String basescript=oscript.toString();
  -             String script=basescript; // May be altered by $$CLASSNAME$$ expansion
  -             
  -             try {
  -                    // Do we already have a class exactly matching this code?
  -                    rexxclass=(Class)codeToClass.get(basescript);
  -                    
  -                    if(rexxclass!=null)
  -                     {
  -                            DebugLog.debugPrintln ("NetRexxEngine: Found 
pre-compiled class" +
  -                                                   " for script '" + basescript + 
"'", DebugLog.BSF_LOG_L3);
  -                            classname=rexxclass.getName();
  -                     }
  -                    else
  -                     {
  -                            gf=openUniqueFile(tempDir,"BSFNetRexx",".nrx");
  -                            if(gf==null)
  -                                throw new BSFException("couldn't create NetRexx 
scratchfile");
  -                            
  -                            // Obtain classname
  -                            classname=gf.className;
  -                            
  -                            // Decide whether to declare a return type
  -                            String returnsDecl="";
  -                            if(returnsObject)
  -                                returnsDecl="returns java.lang.Object";
  -                            
  -                            // Write the kluge header to the file.
  -                            // ***** By doing so we give up the ability to use 
Property blocks.
  -                            gf.fos.write(("class "+classname+";\n")
  -                                         .getBytes());
  -                            gf.fos.write(
  -                                         ("method 
BSFNetRexxEngineEntry(bsf=org.apache.bsf.util.BSFFunctions) "+
  -                                          " public static "+returnsDecl+";\n")
  -                                                              .getBytes());
  -                             
  -                            // Edit the script to replace placeholder with the 
generated
  -                            // classname. Note that this occurs _after_ the cache 
was
  -                            // checked!
  -                            int startpoint,endpoint;
  -                            if((startpoint=script.indexOf(placeholder))>=0)
  -                             {
  -                                    StringBuffer changed=new StringBuffer();
  -                                    for(;
  -                                        startpoint>=0;
  -                                        
startpoint=script.indexOf(placeholder,startpoint))
  -                                     {
  -                                            changed.setLength(0);   // Reset for 
2nd pass or later
  -                                            if(startpoint>0)
  -                                                
changed.append(script.substring(0,startpoint));
  -                                            changed.append(classname);
  -                                            
endpoint=startpoint+placeholder.length();
  -                                            if(endpoint<script.length())
  -                                                
changed.append(script.substring(endpoint));
  -                                            script=changed.toString();
  -                                     }
  -                             }
  -                            
  -                            BSFDeclaredBean tempBean;
  -                            String          className;
  -                            
  -                            for (int i = 0; i < declaredBeans.size (); i++)
  -                             {
  -                                    tempBean  = (BSFDeclaredBean) 
declaredBeans.elementAt (i);
  -                                    className = StringUtils.getClassName 
(tempBean.type);
  -                                    
  -                                    gf.fos.write ((tempBean.name + " =" + className 
+ "   bsf.lookupBean(\"" +
  -                                                   tempBean.name + 
"\");").getBytes());
  -                             }
  -                            
  -                            if(returnsObject)
  -                                gf.fos.write("return ".getBytes());
  -                            
  -                            // Copy the input to the file.
  -                            // Assumes all available -- probably mistake, but same 
as
  -                            // other engines.
  -                            gf.fos.write(script.getBytes());
  -                            gf.fos.close();
  -                            
  -                            DebugLog.debugPrintln ("NetRexxEngine: wrote temp file 
" + 
  -                                                   gf.file.getPath () + ", now 
compiling", DebugLog.BSF_LOG_L3);
  -                            
  -                            // Compile through Java to .class file
  -                    String command=gf.file.getPath(); //classname;
  -                    if (DebugLog.getLogLevel() >= 3) {
  -                        command += " -verbose4";
  -                    } else {
  -                        command += " -noverbose";
  -                        command += " -noconsole";
  +public class NetRexxEngine extends BSFEngineImpl {
  +    BSFFunctions mgrfuncs;
  +    private boolean bsfHandleCreated = false;
  +    static Hashtable codeToClass = new Hashtable();
  +    static String serializeCompilation = "";
  +    static String placeholder = "$$CLASSNAME$$";
  +    String minorPrefix;
  +
  +    /**
  +     * Create a scratchfile, open it for writing, return its name.
  +     * Relies on the filesystem to provide us with uniqueness testing.
  +     * NOTE THAT uniqueFileOffset continues to count; we don't want to
  +     * risk reusing a classname we have previously loaded in this session
  +     * even if the classfile has been deleted.
  +     *
  +     * I've made the offset static, due to concerns about reuse/reentrancy
  +     * of the NetRexx engine.
  +     */
  +    private static int uniqueFileOffset = 0;
  +
  +    private class GeneratedFile {
  +        File file = null;
  +        FileOutputStream fos = null;
  +        String className = null;
  +
  +        GeneratedFile (File file,FileOutputStream fos,String className) {
  +            this.file = file;
  +            this.fos = fos;
  +            this.className = className;
  +        }
  +    }
  +
  +    // rexxclass used to be an instance variable, on the theory that
  +    // each NetRexxEngine was an instance of a specific script.
  +    // BSF is currently reusing Engines, so caching the class
  +    // no longer makes sense.
  +    // Class rexxclass;
  +
  +    /**
  +     * Constructor.
  +     */
  +    public NetRexxEngine () {
  +        /*
  +           The following line is intended to cause the constructor to
  +           throw a NoClassDefFoundError if the NetRexxC.zip dependency
  +           is not resolved.
  +
  +           If this line was not here, the problem would not surface until
  +           the actual processing of a script. We want to know all is well
  +           at the time the engine is instantiated, not when we attempt to
  +           process a script.
  +           */
  +
  +        new netrexx.lang.BadArgumentException();
  +    }
  +
  +    /**
  +     * Return an object from an extension.
  +     * @param Object object from which to call our static method
  +     * @param method The name of the method to call.
  +     * @param args an array of arguments to be
  +     * passed to the extension, which may be either
  +     * Vectors of Nodes, or Strings.
  +     */
  +    public Object call (Object object,String method, Object[] args) 
  +        throws BSFException {
  +
  +        throw new BSFException(BSFException.REASON_UNSUPPORTED_FEATURE,
  +                               "NetRexx doesn't currently support call()",
  +                               null);
  +    }
  +
  +    /**
  +     * Invoke a static method.
  +     * @param rexxclass Class to invoke the method against
  +     * @param method The name of the method to call.
  +     * @param args an array of arguments to be
  +     * passed to the extension, which may be either
  +     * Vectors of Nodes, or Strings.
  +     */
  +    Object callStatic(Class rexxclass, String method, Object[] args) 
  +        throws BSFException {
  +
  +        //***** ISSUE: Currently supports only static methods
  +        Object retval = null;
  +        try
  +        {
  +            if (rexxclass != null)
  +            {
  +                //***** This should call the lookup used in BML, for typesafety
  +                Class[] argtypes=new Class[args.length];
  +                for(int i=0;i<args.length;++i)
  +                    argtypes[i]=args[i].getClass();
  +
  +                Method m=MethodUtils.getMethod(rexxclass, method, argtypes);
  +                retval=m.invoke(null,args);
  +            }
  +            else
  +            {
  +                DebugLog.stderrPrintln ("NetRexxEngine: ERROR: rexxclass==null!", 
  +                                        DebugLog.BSF_LOG_L3);
  +            }
  +        }
  +        catch(Exception e)
  +        {
  +            e.printStackTrace ();
  +            if (e instanceof InvocationTargetException)
  +            {
  +                Throwable t = ((InvocationTargetException)e).getTargetException ();
  +                t.printStackTrace ();
  +            }
  +            throw new BSFException (BSFException.REASON_IO_ERROR,
  +                                    e.getMessage (), e);
  +        }
  +        return retval;
  +    }
  +
  +    public void declareBean (BSFDeclaredBean bean) throws BSFException {}
  +    
  +    /**
  +     * Override impl of execute.
  +     * In NetRexx, methods which do not wish to return a value should be
  +     * invoked via exec, which will cause them to be generated without the
  +     * "returns" clause. Those which wish to return a value should call eval
  +     * instead. which will add "returns java.lang.Object" to the header.
  +     *
  +     * Note: It would be nice to have the "real" return type avaialable, so
  +     * we could do something more type-safe than Object, and so we could
  +     * return primitive types without having to enclose them in their
  +     * object wrappers. BSF does not currently support that concept.
  +     */
  +    public Object eval (Object script) throws BSFException {
  +        return execEvalShared(script, true);
  +    }
  + 
  +    /**
  +     * Override impl of execute.
  +     * In NetRexx, methods which do not wish to return a value should be
  +     * invoked via exec, which will cause them to be generated without the
  +     * "returns" clause. Those which wish to return a value should call eval
  +     * instead. which will add "returns java.lang.Object" to the header.
  +     */
  +    public void exec (Object script) throws BSFException {
  +        execEvalShared(script, false);
  +    }
  +
  +    /**
  +     * This is shared code for the exec() and eval() operations.
  +     * It will evaluate a string containing a NetRexx method body -- which may
  +     * be as simple as a single return statement. It should store the "bsf"
  +     * handle where the script can get to it, for callback purposes.
  +     * <p>
  +     * Note that NetRexx compilation imposes serious overhead -- 11 seconds for
  +     * the first compile, about 3 thereafter -- but in exchange you get
  +     * Java-like speeds once the classes have been created (minus the cache
  +     * lookup cost).
  +     * <p>
  +     * Nobody knows whether javac is threadsafe.
  +     * I'm going to serialize access to the compilers to protect it.
  +     */
  +    public Object execEvalShared (Object oscript,boolean returnsObject)
  +        throws BSFException {
  +
  +        Object retval=null;
  +        String classname=null;
  +        GeneratedFile gf=null;
  +
  +        // Moved into the exec process; see comment above.
  +        Class rexxclass=null;
  +
  +        String basescript=oscript.toString();
  +        String script=basescript; // May be altered by $$CLASSNAME$$ expansion
  +
  +        try {
  +            // Do we already have a class exactly matching this code?
  +            rexxclass=(Class)codeToClass.get(basescript);
  +
  +            if(rexxclass!=null)
  +            {
  +                DebugLog.debugPrintln ("NetRexxEngine: Found pre-compiled class" +
  +                                       " for script '" + basescript + "'", 
DebugLog.BSF_LOG_L3);
  +                classname=rexxclass.getName();
  +            }
  +            else
  +            {
  +                gf=openUniqueFile(tempDir,"BSFNetRexx",".nrx");
  +                if(gf==null)
  +                    throw new BSFException("couldn't create NetRexx scratchfile");
  +
  +                // Obtain classname
  +                classname=gf.className;
  +
  +                // Decide whether to declare a return type
  +                String returnsDecl="";
  +                if(returnsObject)
  +                    returnsDecl="returns java.lang.Object";
  +
  +                // Write the kluge header to the file.
  +                // ***** By doing so we give up the ability to use Property blocks.
  +                gf.fos.write(("class "+classname+";\n")
  +                             .getBytes());
  +                gf.fos.write(
  +                             ("method 
BSFNetRexxEngineEntry(bsf=org.apache.bsf.util.BSFFunctions) "+
  +                              " public static "+returnsDecl+";\n")
  +                             .getBytes());
  +
  +                // Edit the script to replace placeholder with the generated
  +                // classname. Note that this occurs _after_ the cache was
  +                // checked!
  +                int startpoint, endpoint;
  +                if((startpoint=script.indexOf(placeholder))>=0)
  +                {
  +                    StringBuffer changed=new StringBuffer();
  +                    for(;
  +                        startpoint>=0;
  +                        startpoint=script.indexOf(placeholder,startpoint))
  +                    {
  +                        changed.setLength(0);   // Reset for 2nd pass or later
  +                        if(startpoint>0)
  +                            changed.append(script.substring(0,startpoint));
  +                        changed.append(classname);
  +                        endpoint=startpoint+placeholder.length();
  +                        if(endpoint<script.length())
  +                            changed.append(script.substring(endpoint));
  +                        script=changed.toString();
                       }
  -                    
  -                    netrexx.lang.Rexx cmdline= new netrexx.lang.Rexx(command);
  -                    int retValue;
  -                    
  -                    // May not be threadsafe. Serialize access on static object:
  -                    synchronized(serializeCompilation)
  -                        {
  -                            // compile to a .java file
  -                            retValue =
  -                                COM.ibm.netrexx.process.NetRexxC.main(cmdline,
  -                                                                      new 
PrintWriter(DebugLog.getDebugStream()));
  -                        }
  -
  -                             // Check if there were errors while compiling the Rexx 
code.
  -                             if (retValue == 2)
  -                             {
  -                               throw new 
BSFException(BSFException.REASON_EXECUTION_ERROR,
  -                                                                              
"There were NetRexx errors.");
  -                             }
  -
  -                             // Load class.
  -                                DebugLog.debugPrintln ("NetRexxEngine: loading 
class "+classname, DebugLog.BSF_LOG_L3);
  -                             rexxclass=EngineUtils.loadClass (mgr, classname);
  -
  -                             // Stash class for reuse
  -                             codeToClass.put(basescript,rexxclass);
  -                        }
  +                }
  +
  +                BSFDeclaredBean tempBean;
  +                String          className;
   
  -                     Object[] args={mgrfuncs};
  -                     retval=callStatic(rexxclass, "BSFNetRexxEngineEntry",args);
  +                for (int i = 0; i < declaredBeans.size (); i++)
  +                {
  +                    tempBean  = (BSFDeclaredBean) declaredBeans.elementAt (i);
  +                    className = StringUtils.getClassName (tempBean.type);
  +
  +                    gf.fos.write ((tempBean.name + " =" + className + "   
bsf.lookupBean(\"" +
  +                                   tempBean.name + "\");").getBytes());
                   }
  -                catch (BSFException e)
  +
  +                if(returnsObject)
  +                    gf.fos.write("return ".getBytes());
  +
  +                // Copy the input to the file.
  +                // Assumes all available -- probably mistake, but same as
  +                // other engines.
  +                gf.fos.write(script.getBytes());
  +                gf.fos.close();
  +
  +                DebugLog.debugPrintln ("NetRexxEngine: wrote temp file " + 
  +                                       gf.file.getPath () + ", now compiling",
  +                                       DebugLog.BSF_LOG_L3);
  +
  +                // Compile through Java to .class file
  +                String command=gf.file.getPath(); //classname;
  +                if (DebugLog.getLogLevel() >= 3) {
  +                    command += " -verbose4";
  +                } else {
  +                    command += " -noverbose";
  +                    command += " -noconsole";
  +                }
  +
  +                netrexx.lang.Rexx cmdline= new netrexx.lang.Rexx(command);
  +                int retValue;
  +
  +                // May not be threadsafe. Serialize access on static object:
  +                synchronized(serializeCompilation)
  +                {
  +                    // compile to a .java file
  +                    retValue =
  +                        COM.ibm.netrexx.process.NetRexxC.main(cmdline,
  +                                                              new 
PrintWriter(DebugLog.getDebugStream()));
  +                }
  +
  +                // Check if there were errors while compiling the Rexx code.
  +                if (retValue == 2)
  +                {
  +                    throw new BSFException(BSFException.REASON_EXECUTION_ERROR,
  +                                           "There were NetRexx errors.");
  +                }
  +
  +                // Load class.
  +                DebugLog.debugPrintln ("NetRexxEngine: loading class "+classname,
  +                                       DebugLog.BSF_LOG_L3);
  +                rexxclass=EngineUtils.loadClass (mgr, classname);
  +
  +                // Stash class for reuse
  +                codeToClass.put(basescript,rexxclass);
  +            }
  +
  +            Object[] args={mgrfuncs};
  +            retval=callStatic(rexxclass, "BSFNetRexxEngineEntry",args);
  +        }
  +        catch (BSFException e)
  +        {
  +            // Just forward the exception on.
  +            throw e;
  +        }
  +        catch(Exception e)
  +        {
  +            e.printStackTrace ();
  +            if (e instanceof InvocationTargetException)
  +            {
  +                Throwable t = ((InvocationTargetException)e).getTargetException ();
  +                t.printStackTrace ();
  +            }
  +            throw new BSFException (BSFException.REASON_IO_ERROR,
  +                                    e.getMessage (), e);
  +        }
  +        finally
  +        {
  +            // Cleanup: delete the .nrx and .class files
  +            // (if any) generated by NetRexx Trace requests.
  +
  +            if(gf!=null && gf.file!=null && gf.file.exists())
  +                gf.file.delete();  // .nrx file
  +
  +            if(classname!=null)
  +            {
  +                // Generated src
  +                File file=new File(tempDir+File.separatorChar+classname+".java");
  +                if(file.exists())
  +                    file.delete();
  +
  +                // Generated class
  +                file=new File(classname+".class");
  +                if(file.exists())
  +                    file.delete();
  +
  +                // Can this be done without disrupting trace?
  +                file=new File(tempDir+File.separatorChar+classname+".crossref");
  +                if(file.exists())
  +                    file.delete();
  +
  +                // Search for and clean up minor classes, classname$xxx.class
  +                file=new File(tempDir);
  +                minorPrefix=classname+"$"; // Indirect arg to filter
  +                String[] minor_classfiles=
  +                    file.list(
  +                              // ANONYMOUS CLASS for filter:
  +                              new FilenameFilter()
  +                              {
  +                                  // Starts with classname$ and ends with .class
  +                                  public boolean accept(File dir,String name)
  +                                  {
  +                                      return
  +                        (0==name.indexOf(minorPrefix))
  +                        &&
  +                        (name.lastIndexOf(".class")==name.length()-6)
  +                        ;
  +                                  }
  +                              }
  +                             );
  +                if(minor_classfiles!=null)
  +                    for(int i=minor_classfiles.length;i>0;)
                       {
  -                        // Just forward the exception on.
  -                        throw e;
  +                        file=new File(minor_classfiles[--i]);
  +                        file.delete();
                       }
  -                catch(Exception e)
  -                    {
  -                     e.printStackTrace ();
  -                     if (e instanceof InvocationTargetException)
  -                     {
  -                             Throwable t = 
((InvocationTargetException)e).getTargetException ();
  -                             t.printStackTrace ();
  -                     }
  -                     throw new BSFException (BSFException.REASON_IO_ERROR,
  -                                                                     e.getMessage 
(), e);
  -             }
  -             finally
  -             {
  -                     // Cleanup: delete the .nrx and .class files
  -                     // (if any) generated by NetRexx Trace requests.
  -                     
  -                     if(gf!=null && gf.file!=null && gf.file.exists())
  -                             gf.file.delete();  // .nrx file
  -                     
  -                     if(classname!=null)
  -                     {
  -                             // Generated src
  -                             File file=new 
File(tempDir+File.separatorChar+classname+".java");
  -                             if(file.exists())
  -                                     file.delete();
  -                             
  -                             // Generated class
  -                             file=new File(classname+".class");
  -                             if(file.exists())
  -                                     file.delete();
  -                             
  -                             // Can this be done without disrupting trace?
  -                             file=new 
File(tempDir+File.separatorChar+classname+".crossref");
  -                             if(file.exists())
  -                                     file.delete();
  -                             
  -                             // Search for and clean up minor classes, 
classname$xxx.class
  -                             file=new File(tempDir);
  -                             minorPrefix=classname+"$"; // Indirect arg to filter
  -                             String[] minor_classfiles=
  -                                     file.list(
  -                                             // ANONYMOUS CLASS for filter:
  -                                             new FilenameFilter()
  -                                             {
  -                                                     // Starts with classname$ and 
ends with .class
  -                                                     public boolean accept(File 
dir,String name)
  -                                                     {
  -                                                             return
  -                                                                     
(0==name.indexOf(minorPrefix))
  -                                                                     &&
  -                                                                     
(name.lastIndexOf(".class")==name.length()-6)
  -                                                                     ;
  -                                                     }
  -                                             }
  -                                             );
  -                             if(minor_classfiles!=null)
  -                                     for(int i=minor_classfiles.length;i>0;)
  -                                     {
  -                                             file=new File(minor_classfiles[--i]);
  -                                             file.delete();
  -                                     }
  -                     }
  -             }
  -             
  -             return retval;
  -     }
  -     public void initialize(BSFManager mgr, String lang,Vector declaredBeans)
  -     throws BSFException
  -     {
  -             super.initialize(mgr, lang, declaredBeans);
  -             mgrfuncs = new BSFFunctions (mgr, this);
  -     }
  -private GeneratedFile openUniqueFile(String directory,String prefix,String suffix)
  -     {
  -             File file=null,obj=null;
  -             FileOutputStream fos=null;
  -             int max=1000;           // Don't try forever
  -             GeneratedFile gf=null;
  -             int i;
  -             String className = null;
  -             for(i=max,++uniqueFileOffset;
  -                     fos==null && i>0;
  -                     --i,++uniqueFileOffset)     
  -             {
  -                     // Probably a timing hazard here... ***************
  -                     try
  -                             {
  -                                     className = prefix+uniqueFileOffset;
  -                                     file=new 
File(directory+File.separatorChar+className+suffix);
  -                                     obj=new 
File(directory+File.separatorChar+className+".class");
  -                                     if(file!=null && !file.exists() & obj!=null & 
!obj.exists())
  -                                             fos=new FileOutputStream(file);
  -                             }
  -                     catch(Exception e)
  -                             {
  -                                     // File could not be opened for write, or 
Security Exception
  -                                     // was thrown. If someone else created the 
file before we could
  -                                     // open it, that's probably a threading 
conflict and we don't
  -                                     // bother reporting it.
  -                                     if(!file.exists())
  -                                     {
  -                                             
DebugLog.stderrPrintln("openUniqueFile: unexpected "+e, DebugLog.BSF_LOG_L0);
  -                                     }
  -                             }
  -             }
  -             if(fos==null)
  -                     DebugLog.stderrPrintln("openUniqueFile: Failed 
"+max+"attempts.", DebugLog.BSF_LOG_L0);
  -             else
  -                     gf=new GeneratedFile(file,fos,className);
  -             return gf;
  -     }
  +            }
  +        }
  +
  +        return retval;
  +    }
  +
  +    public void initialize(BSFManager mgr, String lang,Vector declaredBeans)
  +        throws BSFException {
  +
  +        super.initialize(mgr, lang, declaredBeans);
  +        mgrfuncs = new BSFFunctions (mgr, this);
  +    }
  +
  +    private GeneratedFile openUniqueFile(String directory, String prefix,
  +                                         String suffix) {
  +        File file=null,obj=null;
  +        FileOutputStream fos=null;
  +        int max=1000;           // Don't try forever
  +        GeneratedFile gf=null;
  +        int i;
  +        String className = null;
  +        for(i=max,++uniqueFileOffset;
  +            fos==null && i>0;
  +            --i,++uniqueFileOffset)     
  +        {
  +            // Probably a timing hazard here... ***************
  +            try
  +            {
  +                className = prefix+uniqueFileOffset;
  +                file=new File(directory+File.separatorChar+className+suffix);
  +                obj=new File(directory+File.separatorChar+className+".class");
  +                if(file!=null && !file.exists() & obj!=null & !obj.exists())
  +                    fos=new FileOutputStream(file);
  +            }
  +            catch(Exception e)
  +            {
  +                // File could not be opened for write, or Security Exception
  +                // was thrown. If someone else created the file before we could
  +                // open it, that's probably a threading conflict and we don't
  +                // bother reporting it.
  +                if(!file.exists())
  +                {
  +                    DebugLog.stderrPrintln("openUniqueFile: unexpected "+e, 
DebugLog.BSF_LOG_L0);
  +                }
  +            }
  +        }
  +        if(fos==null)
  +            DebugLog.stderrPrintln("openUniqueFile: Failed "+max+"attempts.", 
DebugLog.BSF_LOG_L0);
  +        else
  +            gf=new GeneratedFile(file,fos,className);
  +        return gf;
  +    }
   
  -     public void undeclareBean (BSFDeclaredBean bean) throws BSFException {}
  +    public void undeclareBean (BSFDeclaredBean bean) throws BSFException {}
   }
  
  
  
  1.2       +5 -6      jakarta-bsf/src/org/apache/bsf/engines/xslt/XSLTEngine.java
  
  Index: XSLTEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/engines/xslt/XSLTEngine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSLTEngine.java   25 Jun 2003 09:14:21 -0000      1.1
  +++ XSLTEngine.java   8 Jul 2003 02:56:50 -0000       1.2
  @@ -111,8 +111,7 @@
        * Evaluate an expression. In this case, an expression is assumed
        * to be a stylesheet of the template style (see the XSLT spec).
        */
  -    public Object eval (String source, int lineNo, int columnNo, 
  -                        Object oscript) throws BSFException {
  +    public Object eval (Object oscript) throws BSFException {
        // get the style base URI (the place from where Xerces XSLT will
        // look for imported/included files and referenced docs): if a
        // bean named "xslt:styleBaseURI" is registered, then cvt it
  @@ -208,10 +207,10 @@
       /**
        * Initialize the engine.
        */
  -    public void initialize (BSFManager mgr, String lang,
  -                            Vector declaredBeans) throws BSFException {
  -     super.initialize (mgr, lang, declaredBeans);
  -
  +    public void initialize (BSFManager mgr, String lang, Vector declaredBeans)
  +        throws BSFException {
  +        
  +        super.initialize (mgr, lang, declaredBeans);
           tFactory = TransformerFactory.newInstance();
       }
   
  
  
  
  1.2       +23 -23    jakarta-bsf/src/org/apache/bsf/util/BSFEngineImpl.java
  
  Index: BSFEngineImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/util/BSFEngineImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BSFEngineImpl.java        25 Jun 2003 09:14:21 -0000      1.1
  +++ BSFEngineImpl.java        8 Jul 2003 02:56:50 -0000       1.2
  @@ -80,31 +80,30 @@
       protected ClassLoader classLoader;
   
       /**
  -     * Default impl of apply - calls eval ignorning parameters and returns
  +     * Default impl of apply - calls eval ignoring parameters and returns
        * the result.
        */
  -    public Object apply(String source, int lineNo, int columnNo, 
  -                        Object funcBody, Vector paramNames, Vector arguments)
  +    public Object apply(Object funcBody, Vector paramNames, Vector arguments)
           throws BSFException {
  -        return eval(source, lineNo, columnNo, funcBody);
  +
  +        return eval(funcBody);
       }
   
       /**
  -     * Default impl of compileApply - calls compileExpr ignorning parameters.
  +     * Default impl of compileApply - calls compileExpr ignoring parameters.
        */
  -    public void compileApply(String source, int lineNo, int columnNo,
  -                             Object funcBody, Vector paramNames, 
  +    public void compileApply(Object funcBody, Vector paramNames, 
                                Vector arguments, CodeBuffer cb)
           throws BSFException {
  -        compileExpr(source, lineNo, columnNo, funcBody, cb);
  +
  +        compileExpr(funcBody, cb);
       }
   
       /**
        * Default impl of compileExpr - generates code that'll create a new
        * manager, evaluate the expression, and return the value.
        */
  -    public void compileExpr(String source, int lineNo, int columnNo,
  -                            Object expr, CodeBuffer cb) throws BSFException {
  +    public void compileExpr(Object expr, CodeBuffer cb) throws BSFException {
           ObjInfo bsfInfo = cb.getSymbol("bsf");
           
           if (bsfInfo == null) {
  @@ -115,8 +114,7 @@
           }
   
           String evalString = bsfInfo.objName + ".eval(\"" + lang + "\", ";
  -        evalString += "request.getRequestURI(), " + lineNo + ", " + columnNo;
  -        evalString += "," + StringUtils.lineSeparator;
  +        evalString += StringUtils.lineSeparator;
           evalString += StringUtils.getSafeString(expr.toString()) + ")";
   
           ObjInfo oldRet = cb.getFinalServiceMethodStatement();
  @@ -135,9 +133,9 @@
        * Default impl of compileScript - generates code that'll create a new
        * manager, and execute the script.
        */
  -    public void compileScript(String source, int lineNo, int columnNo,
  -                              Object script, CodeBuffer cb) 
  +    public void compileScript(Object script, CodeBuffer cb) 
           throws BSFException {
  +
           ObjInfo bsfInfo = cb.getSymbol("bsf");
           
           if (bsfInfo == null) {
  @@ -148,8 +146,7 @@
           }
   
           String execString = bsfInfo.objName + ".exec(\"" + lang + "\", ";
  -        execString += "request.getRequestURI(), " + lineNo + ", " + columnNo;
  -        execString += "," + StringUtils.lineSeparator;
  +        execString += StringUtils.lineSeparator;
           execString += StringUtils.getSafeString(script.toString()) + ")";
   
           ObjInfo oldRet = cb.getFinalServiceMethodStatement();
  @@ -172,23 +169,26 @@
       /**
        * Default impl of execute - calls eval and ignores the result.
        */
  -    public void exec(String source, int lineNo, int columnNo, Object script)
  +    public void exec(Object script)
           throws BSFException {
  -        eval(source, lineNo, columnNo, script);
  +
  +        eval(script);
       }
   
       /**
        * Default impl of interactive execution - calls eval and ignores the result.
        */
  -    public void iexec(String source, int lineNo, int columnNo, Object script)
  +    public void iexec(Object script)
           throws BSFException {
  -        eval(source, lineNo, columnNo, script);
  +
  +        eval(script);
       }
   
       /**
  -     * initialize the engine; called right after construction by 
  -     * the manager. Declared beans are simply kept in a vector and
  -     * that's it. Subclasses must do whatever they want with it.
  +     * Initialize the engine; called right after construction by 
  +     * the manager. 
  +     * Declared beans are simply kept in a vector and that's it. Subclasses
  +     * must do whatever they want with it.
        */
       public void initialize(BSFManager mgr, String lang, Vector declaredBeans)
           throws BSFException {
  
  
  
  1.2       +2 -8      jakarta-bsf/src/org/apache/bsf/util/BSFEventProcessor.java
  
  Index: BSFEventProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/util/BSFEventProcessor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BSFEventProcessor.java    25 Jun 2003 09:14:21 -0000      1.1
  +++ BSFEventProcessor.java    8 Jul 2003 02:56:50 -0000       1.2
  @@ -69,9 +69,6 @@
     BSFEngine engine;
     BSFManager manager;
     String filter;
  -  String source;
  -  int lineNo;
  -  int columnNo;
     Object script;
   
     /**
  @@ -79,14 +76,11 @@
      * public use.
      */
     BSFEventProcessor (BSFEngine engine, BSFManager manager, String filter,
  -                  String source, int lineNo, int columnNo, Object script)
  +                  Object script)
           throws BSFException {
        this.engine = engine;
        this.manager = manager;
        this.filter = filter;
  -     this.source = source;
  -     this.lineNo = lineNo;
  -     this.columnNo = columnNo;
        this.script = script;
     }
     //////////////////////////////////////////////////////////////////////////
  @@ -125,6 +119,6 @@
        }
   
        // run the script
  -     engine.exec (source, lineNo, columnNo, script);
  +     engine.exec (script);
     }
   }
  
  
  
  1.2       +1 -1      jakarta-bsf/src/org/apache/bsf/util/BSFFunctions.java
  
  Index: BSFFunctions.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/util/BSFFunctions.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BSFFunctions.java 25 Jun 2003 09:14:21 -0000      1.1
  +++ BSFFunctions.java 8 Jul 2003 02:56:50 -0000       1.2
  @@ -78,7 +78,7 @@
                                String filter, Object script)
           throws BSFException {
        EngineUtils.addEventListener (src, eventSetName, filter, engine, 
  -                               mgr, "<event-binding>", 0, 0, script);
  +                               mgr, script);
     }
     public  Object lookupBean (String name) {
        return mgr.lookupBean (name);
  
  
  
  1.2       +3 -8      jakarta-bsf/src/org/apache/bsf/util/EngineUtils.java
  
  Index: EngineUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bsf/src/org/apache/bsf/util/EngineUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EngineUtils.java  25 Jun 2003 09:14:21 -0000      1.1
  +++ EngineUtils.java  8 Jul 2003 02:56:50 -0000       1.2
  @@ -86,21 +86,16 @@
        * @param filter       filter for events
        * @param engine       BSFEngine which can run this script
        * @param manager      BSFManager of the above engine
  -     * @param source       (context info) the source of this expression 
  -     *                                    (e.g., filename)
  -     * @param lineNo       (context info) the line number in source for expr
  -     * @param columnNo     (context info) the column number in source for expr
        * @param script       the script to execute when the event occurs
        *
        * @exception BSFException if anything goes wrong while running the script
        */
       public static void addEventListener (Object bean, String eventSetName,
                                            String filter, BSFEngine engine, 
  -                                         BSFManager manager, String source,
  -                                         int lineNo, int columnNo, 
  -                                         Object script) throws BSFException {
  +                                         BSFManager manager, Object script)
  +        throws BSFException {
  +
           BSFEventProcessor ep = new BSFEventProcessor (engine, manager, filter,
  -                                                      source, lineNo, columnNo,
                                                         script);
           
           try {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to