Package org.apache.bsf

Examples of org.apache.bsf.BSFException


            //runtime.setPosition(file, line);
            IRubyObject result = runtime.evalScriptlet(expr.toString());
            return JavaEmbedUtils.rubyToJava(runtime, result, Object.class);
        } catch (Exception excptn) {
            excptn.printStackTrace();
            throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "Exception", excptn);
        }
    }
View Full Code Here


          // See eval todo about why this is commented out
            //runtime.setPosition(file, line);
            runtime.evalScriptlet(expr.toString());
        } catch (Exception excptn) {
            excptn.printStackTrace();
            throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "Exception", excptn);
        }
    }
View Full Code Here

        try {
          return JavaEmbedUtils.invokeMethod(runtime, recv, method, args, Object.class);
        } catch (Exception excptn) {
            excptn.printStackTrace();
            printException(runtime, excptn);
            throw new BSFException(BSFException.REASON_EXECUTION_ERROR, excptn.getMessage(), excptn);
        }
    }
View Full Code Here

                jExpr = ScriptFactory.createScript((String) expr);
            }
            return jExpr.execute(jc);
        } catch (Exception e) {
            // TODO Better messages
            throw new BSFException(e.getMessage());
        }
    }
View Full Code Here

            } else {
                jExpr = ScriptFactory.createScript((String) script);
            }
            jExpr.execute(jc);
        } catch (Exception e) {
            throw new BSFException(e.getMessage());
        }
    }
View Full Code Here

                types[i] = args[i].getClass();
            }
            Method m = object.getClass().getMethod(name, types);
            return m.invoke(object, args);
        } catch (Exception e) {
            throw new BSFException(e.getMessage());
        }
    }
View Full Code Here

     * The object may be null to indicate the global namespace of the
     * interpreter.
     * @param object may be null for the global namespace.
     */
    public Object call(Object object, String name, Object[] args) throws BSFException {
        throw new BSFException("The call method is not yet supported for SimpleMethods");
    }
View Full Code Here

     */
    public Object apply(String source, int lineNo, int columnNo, Object funcBody, Vector namesVec, Vector argsVec) throws BSFException {
        //if (namesVec.size() != argsVec.size()) throw new BSFException("number of params/names mismatch");
        //if (!(funcBody instanceof String)) throw new BSFException("apply: function body must be a string");

        throw new BSFException("The apply method is not yet supported for simple-methods");
    }
View Full Code Here

        throw new BSFException("The apply method is not yet supported for simple-methods");
    }

    public Object eval(String source, int lineNo, int columnNo, Object expr) throws BSFException {
        if (!(expr instanceof String)) throw new BSFException("simple-method expression must be a string");

        //right now only supports one method per file, so get all methods and just run the first...
        Map<String, SimpleMethod> simpleMethods = null;
        try {
            simpleMethods = SimpleMethod.getDirectSimpleMethods(source, (String) expr, "<bsf source>");
        } catch (MiniLangException e) {
            throw new BSFException("Error loading/parsing simple-method XML source: " + e.getMessage());
        }
        Set<String> smNames = simpleMethods.keySet();
        if (smNames.size() == 0) throw new BSFException("Did not find any simple-methods in the file");

        String methodName = smNames.iterator().next();
        if (smNames.size() > 1) Debug.logWarning("Found more than one simple-method in the file, running the [" + methodName + "] method, you should remove all but one method from this file", module);

        SimpleMethod simpleMethod = simpleMethods.get(methodName);
View Full Code Here

            try {
                String script=FileUtils.readFileToString(new File(scriptFile));
                bsfEngine.exec(scriptFile,0,0,script);
            } catch (IOException e) {
                log.warn(e.getLocalizedMessage());
                throw new BSFException(BSFException.REASON_IO_ERROR,"Problem reading script file",e);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.bsf.BSFException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.