jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From orlikow...@apache.org
Subject cvs commit: jakarta-bsf/src/org/apache/bsf BSFManager.java
Date Tue, 08 Jul 2003 18:57:20 GMT
orlikowski    2003/07/08 11:57:19

  Modified:    src/org/apache/bsf BSFManager.java
  Log:
  Deprecate rather than remove the old method signatures.
  These are wrappers over the new methods.
  
  The floor is open to make the case for the old method signatures to remain.
  
  Submitted by: Stefan Bodewig <bodewig@apache.org>
  Reviewed by: Victor J. Orlikowski <orlikowski@apache.org>
  
  Revision  Changes    Path
  1.3       +236 -54   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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BSFManager.java	8 Jul 2003 02:56:49 -0000	1.2
  +++ BSFManager.java	8 Jul 2003 18:57:19 -0000	1.3
  @@ -129,14 +129,14 @@
               ResourceBundle rb =
                   ResourceBundle.getBundle("org.apache.bsf.Languages");
               Enumeration keys = rb.getKeys();
  -            
  +
               while (keys.hasMoreElements()) {
                   String key = (String) keys.nextElement();
                   String value = rb.getString(key);
  -                
  +
                   StringTokenizer tokens = new StringTokenizer(value, ",");
                   String className = (String) tokens.nextToken();
  -                
  +
                   // get the extensions for this language
                   String exts = (String) tokens.nextToken();
                   StringTokenizer st = new StringTokenizer(exts, "|");
  @@ -144,7 +144,7 @@
                   for (int i = 0; st.hasMoreTokens(); i++) {
                       extensions[i] = ((String) st.nextToken()).trim();
                   }
  -                
  +
                   registerScriptingEngine(key, className, extensions);
               }
           }
  @@ -167,6 +167,34 @@
        * parameters and return the resulting value.
        *
        * @param lang language identifier
  +     * @param source <b>ignored</b>
  +     * @param lineNo <b>ignored</b>
  +     * @param columnNo <b>ignored</b>
  +     * @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
  +     *
  +     * @deprecated use the four-arg version instead.
  +     */
  +    public Object apply(String lang,
  +                        String source,
  +                        int lineNo,
  +                        int columnNo,
  +                        Object funcBody,
  +                        Vector paramNames,
  +                        Vector arguments)
  +        throws BSFException {
  +
  +        return apply(lang, funcBody, paramNames, arguments);
  +    }
  +
  +    /**
  +     * Apply the given anonymous function of the given language to the given
  +     * parameters and return the resulting value.
  +     *
  +     * @param lang language identifier
        * @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
  @@ -186,10 +214,10 @@
           try {
               final Object resultf = 
                   AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                        public Object run() throws Exception {
  -                            return e.apply(funcBodyf, paramNamesf, argumentsf);
  -                        }
  -                    });
  +                    public Object run() throws Exception {
  +                        return e.apply(funcBodyf, paramNamesf, argumentsf);
  +                    }
  +                });
               result = resultf;
           }
           catch (PrivilegedActionException prive) {
  @@ -204,6 +232,36 @@
        * language to the given parameters into the given <tt>CodeBuffer</tt>.
        *
        * @param lang language identifier
  +     * @param source <b>ignored</b>
  +     * @param lineNo <b>ignored</b>
  +     * @param columnNo <b>ignored</b>
  +     * @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
  +     * @param cb       code buffer to compile into
  +     *
  +     * @exception BSFException if anything goes wrong while running the script
  +     *
  +     * @deprecated use the five-arg version instead.
  +     */
  +    public void compileApply(String lang,
  +                             String source,
  +                             int lineNo,
  +                             int columnNo,
  +                             Object funcBody,
  +                             Vector paramNames,
  +                             Vector arguments,
  +                             CodeBuffer cb)
  +        throws BSFException {
  +
  +        compileApply(lang, funcBody, paramNames, arguments, cb);
  +    }
  +
  +    /**
  +     * Compile the application of the given anonymous function of the given
  +     * language to the given parameters into the given <tt>CodeBuffer</tt>.
  +     *
  +     * @param lang language identifier
        * @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
  @@ -220,15 +278,15 @@
           final Vector paramNamesf = paramNames;
           final Vector argumentsf = arguments;
           final CodeBuffer cbf = cb;
  -        
  +
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                    public Object run() throws Exception {
  -                        e.compileApply(funcBodyf, paramNamesf, 
  -                                       argumentsf, cbf);
  -                        return null;
  -                    }
  -                });
  +                public Object run() throws Exception {
  +                    e.compileApply(funcBodyf, paramNamesf, 
  +                                   argumentsf, cbf);
  +                    return null;
  +                }
  +            });
           }
           catch (PrivilegedActionException prive) {
               throw (BSFException) prive.getException();
  @@ -240,6 +298,32 @@
        * <tt>CodeBuffer</tt>.
        *
        * @param lang     language identifier
  +     * @param source   <b>ignored</b>
  +     * @param lineNo   <b>ignored</b>
  +     * @param columnNo <b>ignored</b>
  +     * @param expr     the expression to compile
  +     * @param cb       code buffer to compile into
  +     *
  +     * @exception BSFException if any error while compiling the expression
  +     *
  +     * @deprecated use the three-arg version instead.
  +     */
  +    public void compileExpr(String lang,
  +                            String source,
  +                            int lineNo,
  +                            int columnNo,
  +                            Object expr,
  +                            CodeBuffer cb)
  +        throws BSFException {
  +
  +        compileExpr(lang, expr, cb);
  +    }
  +
  +    /**
  +     * Compile the given expression of the given language into the given 
  +     * <tt>CodeBuffer</tt>.
  +     *
  +     * @param lang     language identifier
        * @param expr     the expression to compile
        * @param cb       code buffer to compile into
        *
  @@ -254,11 +338,11 @@
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                    public Object run() throws Exception {
  -                        e.compileExpr(exprf, cbf);
  -                        return null;
  -                    }
  -                });
  +                public Object run() throws Exception {
  +                    e.compileExpr(exprf, cbf);
  +                    return null;
  +                }
  +            });
           }
           catch (PrivilegedActionException prive) {
               throw (BSFException) prive.getException();
  @@ -270,6 +354,32 @@
        * <tt>CodeBuffer</tt>.
        *
        * @param lang     language identifier
  +     * @param source   <b>ignored</b>
  +     * @param lineNo   <b>ignored</b>
  +     * @param columnNo <b>ignored</b>
  +     * @param script   the script to compile
  +     * @param cb       code buffer to compile into
  +     *
  +     * @exception BSFException if any error while compiling the script
  +     *
  +     * @deprecated use the three-arg version instead.
  +     */
  +    public void compileScript(String lang,
  +                              String source,
  +                              int lineNo,
  +                              int columnNo,
  +                              Object script,
  +                              CodeBuffer cb)
  +        throws BSFException {
  +
  +        compileScript(lang, script, cb);
  +    }
  +
  +    /**
  +     * Compile the given script of the given language into the given 
  +     * <tt>CodeBuffer</tt>.
  +     *
  +     * @param lang     language identifier
        * @param script   the script to compile
        * @param cb       code buffer to compile into
        *
  @@ -284,11 +394,11 @@
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                    public Object run() throws Exception {
  -                        e.compileScript(scriptf, cbf);
  -                        return null;
  -                    }
  -                });
  +                public Object run() throws Exception {
  +                    e.compileScript(scriptf, cbf);
  +                    return null;
  +                }
  +            });
           }
           catch (PrivilegedActionException prive) {
               throw (BSFException) prive.getException();
  @@ -296,12 +406,13 @@
       }
   
       /**
  -     * Declare a bean. The difference between declaring and registering 
  -     * is that engines are spsed to make declared beans "pre-available"
  -     * in the scripts as far as possible. That is, if a script author
  -     * needs a registered bean, he needs to look it up in some way. However
  -     * if he needs a declared bean, the language has the responsibility to
  -     * make those beans avaialable "automatically."
  +     * Declare a bean. 
  +     * The difference between declaring and registering is that engines are
  +     * spsed to make declared beans "pre-available" in the scripts as far as
  +     * possible. That is, if a script author needs a registered bean, he needs
  +     * to look it up in some way. However if he needs a declared bean, the
  +     * language has the responsibility to make those beans avaialable
  +     * "automatically."
        * <p>
        * When a bean is declared it is automatically registered as well
        * so that any declared bean can be gotton to by looking it up as well.
  @@ -327,7 +438,7 @@
        */
       public void declareBean(String beanName, Object bean, Class type)
           throws BSFException {
  -        
  +
           registerBean(beanName, bean);
   
           BSFDeclaredBean tempBean = new BSFDeclaredBean(beanName, bean, type);
  @@ -346,6 +457,30 @@
        * resulting value.
        *
        * @param lang language identifier
  +     * @param source <b>ignored</b>
  +     * @param lineNo <b>ignored</b>
  +     * @param columnNo <b>ignored</b>
  +     * @param expr the expression to evaluate
  +     *
  +     * @exception BSFException if anything goes wrong while running the script
  +     *
  +     * @deprecated use the two-arg version instead.
  +     */
  +    public Object eval(String lang,
  +                       String source,
  +                       int lineNo,
  +                       int columnNo,
  +                       Object expr)
  +        throws BSFException {
  +     
  +        return eval(lang, expr);
  +    }
  +
  +    /**
  +     * Evaluate the given expression of the given language and return the
  +     * resulting value.
  +     *
  +     * @param lang language identifier
        * @param expr the expression to evaluate
        *
        * @exception BSFException if anything goes wrong while running the script
  @@ -356,14 +491,14 @@
           final BSFEngine e = loadScriptingEngine(lang);
           final Object exprf = expr;
           Object result = null;
  -        
  +
           try {
               final Object resultf =
                   AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                        public Object run() throws Exception {
  -                            return e.eval(exprf);
  -                        }
  -                    });
  +                    public Object run() throws Exception {
  +                        return e.eval(exprf);
  +                    }
  +                });
               result = resultf;
           }
           catch (PrivilegedActionException prive) {
  @@ -384,6 +519,29 @@
        * Execute the given script of the given language.
        *
        * @param lang     language identifier
  +     * @param source   <b>ignored</b>
  +     * @param lineNo   <b>ignored</b>
  +     * @param columnNo <b>ignored</b>
  +     * @param script   the script to execute
  +     *
  +     * @exception BSFException if anything goes wrong while running the script
  +     *
  +     * @deprecated use the two-arg version instead.
  +     */
  +    public void exec(String lang,
  +                     String source,
  +                     int lineNo,
  +                     int columnNo,
  +                     Object script)
  +        throws BSFException {
  +
  +        exec(lang, script);
  +    }
  +
  +    /**
  +     * Execute the given script of the given language.
  +     *
  +     * @param lang     language identifier
        * @param script   the script to execute
        *
        * @exception BSFException if anything goes wrong while running the script
  @@ -396,11 +554,11 @@
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                    public Object run() throws Exception {
  -                        e.exec(scriptf);
  -                        return null;
  -                    }
  -                });
  +                public Object run() throws Exception {
  +                    e.exec(scriptf);
  +                    return null;
  +                }
  +            });
           }
           catch (PrivilegedActionException prive) {
               throw (BSFException) prive.getException();
  @@ -412,6 +570,30 @@
        * emulate an interactive session w/ the language.
        *
        * @param lang     language identifier
  +     * @param source   <b>ignored</b>
  +     * @param lineNo   <b>ignored</b>
  +     * @param columnNo <b>ignored</b>
  +     * @param script   the script to execute
  +     *
  +     * @exception BSFException if anything goes wrong while running the script
  +     *
  +     * @deprecated use the two-arg version instead.
  +     */
  +    public void iexec(String lang,
  +                      String source,
  +                      int lineNo,
  +                      int columnNo,
  +                      Object script)
  +        throws BSFException {
  +
  +        iexec(lang, script);
  +    }
  +
  +    /**
  +     * Execute the given script of the given language, attempting to
  +     * emulate an interactive session w/ the language.
  +     *
  +     * @param lang     language identifier
        * @param script   the script to execute
        *
        * @exception BSFException if anything goes wrong while running the script
  @@ -424,11 +606,11 @@
   
           try {
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                    public Object run() throws Exception {
  -                        e.iexec(scriptf);
  -                        return null;
  -                    }
  -                });
  +                public Object run() throws Exception {
  +                    e.iexec(scriptf);
  +                    return null;
  +                }
  +            });
           }
           catch (PrivilegedActionException prive) {
               throw (BSFException) prive.getException();
  @@ -505,7 +687,7 @@
                   }
                   if (loops == 0) lang = langval;
               }
  -            
  +
               if (lang != null && lang != "") {
                   return lang;
               }
  @@ -587,18 +769,18 @@
               final String langf = lang;
               final Vector dbf = declaredBeans;
               AccessController.doPrivileged(new PrivilegedExceptionAction() {
  -                    public Object run() throws Exception {
  -                        engf.initialize(thisf, langf, dbf);
  -                        return null;
  -                    }
  -                });
  +                public Object run() throws Exception {
  +                    engf.initialize(thisf, langf, dbf);
  +                    return null;
  +                }
  +            });
               eng = engf;
               loadedEngines.put(lang, eng);
               pcs.addPropertyChangeListener(eng);
               return eng;
           } 
           catch (PrivilegedActionException prive) {
  -                throw (BSFException) prive.getException();
  +            throw (BSFException) prive.getException();
           }
           catch (Throwable t) {
               throw new BSFException(BSFException.REASON_OTHER_ERROR,
  
  
  

Mime
View raw message