Examples of BSFException


Examples of org.apache.bsf.BSFException

     * arguments.
     */
    @SuppressWarnings("unchecked")
    @Override
    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");

        String [] names = new String [ namesVec.size() ];
        namesVec.copyInto(names);
        Object [] args = new String [ argsVec.size() ];
        argsVec.copyInto(args);

        try {
            if (!installedApplyMethod) {
                interpreter.eval(bsfApplyMethod);
                installedApplyMethod = true;
            }

            bsh.This global = (bsh.This)interpreter.get("global");
            return global.invokeMethod("_bsfApply", new Object [] { names, args, (String)funcBody });

        } catch (InterpreterError e) {
            throw new BSFException("BeanShell interpreter internal error: " + e + sourceInfo(source,lineNo,columnNo));
        } catch (TargetError e2) {
            throw new BSFException("The application script threw an exception: " + e2.getTarget() + sourceInfo(source,lineNo,columnNo));
        } catch (EvalError e3) {
            throw new BSFException("BeanShell script error: " + e3 + sourceInfo(source,lineNo,columnNo));
        }
    }
View Full Code Here

Examples of org.apache.bsf.BSFException

            throw new BSFException("BeanShell script error: " + e3 + sourceInfo(source,lineNo,columnNo));
        }
    }

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

        try {
            //return interpreter.eval(((String) expr));

            Interpreter.ParsedScript script = null;

            if (UtilValidate.isNotEmpty(source)) {
                script = parsedScripts.get(source);
                if (script == null) {
                    synchronized (OfbizBshBsfEngine.class) {
                        script = parsedScripts.get(source);
                        if (script == null) {
                            script = interpreter.parseScript(source, new StringReader((String) expr));
                            Debug.logVerbose("Caching BSH script at: " + source, module);
                            parsedScripts.put(source, script);
                        }
                    }
                }
            } else {
                script = interpreter.parseScript(source, new StringReader((String) expr));
            }

            return interpreter.evalParsedScript(script);
        } catch (InterpreterError e) {
            throw new BSFException("BeanShell interpreter internal error: "+ e + sourceInfo(source,lineNo,columnNo));
        } catch (TargetError e2) {
            Debug.logError(e2, "Error thrown in BeanShell script called through BSF at: " + sourceInfo(source,lineNo,columnNo), module);
            //Debug.logError(e2.getTarget(), module);
            throw new BSFException("The application script threw an exception: " + e2 + " " + sourceInfo(source,lineNo,columnNo));
        } catch (EvalError e3) {
            throw new BSFException("BeanShell script error: " + e3 + sourceInfo(source,lineNo,columnNo));
        }
    }
View Full Code Here

Examples of org.apache.bsf.BSFException

    @Override
    public void declareBean(BSFDeclaredBean bean) throws BSFException {
        try {
            interpreter.set(bean.name, bean.bean);
        } catch (EvalError e) {
            throw new BSFException("error declaring bean: " + bean.name + " : " + e.toString());
        }
    }
View Full Code Here

Examples of org.apache.bsf.BSFException

    @Override
    public void undeclareBean(BSFDeclaredBean bean) throws BSFException {
        try {
            interpreter.unset(bean.name);
        } catch (EvalError e) {
            throw new BSFException("bsh internal error: " + e.toString());
        }
    }
View Full Code Here

Examples of org.apache.bsf.BSFException

  } catch (Exception e) {
    // something went wrong while invoking method
    Throwable t = (e instanceof InvocationTargetException) ?
              ((InvocationTargetException)e).getTargetException () :
              null;
    throw new BSFException (BSFException.REASON_OTHER_ERROR,
            "method invocation failed: " + e +
            ((t==null)?"":(" target exception: "+t)), t);
  }
  }
View Full Code Here

Examples of org.apache.bsf.BSFException

   * 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 {
  throw new BSFException (BSFException.REASON_UNSUPPORTED_FEATURE,
          "Java bytecode engine can't evaluate expressions");
  }
View Full Code Here

Examples of org.apache.bsf.BSFException

            // corrected the situation by aborting the loop and
            // a long stacktrace would end up on the user's console
            throw (Error) t;
        }
        else {
            throw new BSFException(BSFException.REASON_OTHER_ERROR,
                                   "JavaScript Error: " + message,
                                   target);
        }
    }
View Full Code Here

Examples of org.apache.bsf.BSFException

    if (internalRep instanceof TclInteger)
    return new Integer(TclInteger.get(interp,result));

    return result;
  } catch (TclException e) {
    throw new BSFException (BSFException.REASON_EXECUTION_ERROR,
            "error while eval'ing Jacl expression: " +
            interp.getResult (), e);
  }
  }
View Full Code Here

Examples of org.apache.bsf.BSFException

  // Make java functions be available to Jacl
        try {
       interp.eval("jaclloadjava");
  } catch (TclException e) {
    throw new BSFException (BSFException.REASON_OTHER_ERROR,
          "error while loading java package: " +
          interp.getResult (), e);
  }

  int size = declaredBeans.size ();
View Full Code Here

Examples of org.apache.bsf.BSFException

    /**
     * call the named method of the given object.
     */
    public Object call (Object object, String method, Object[] args)
        throws BSFException {
  throw new BSFException (BSFException.REASON_UNSUPPORTED_FEATURE,
                                "BSF:XSLTEngine can't call methods");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.