Package org.apache.bsf

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


    @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

  } 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

   * 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

            // 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

    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

  // 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

    /**
     * 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

        try {
            transformer = tFactory.newTransformer(styleSource);
        } catch (Exception e) {
          logger.error("Exception from Xerces XSLT:", e);
            throw new BSFException (BSFException.REASON_EXECUTION_ERROR,
                                    "Exception from Xerces XSLT: " + e, e);
        }

  // get the src to work on: if a bean named "xslt:src" is registered
  // and its a Node, then use it as the source. If its not a Node, then
  // if its a URL parse it, if not treat it as a file and make a URL and
  // parse it and go. If no xslt:src is found, use an empty document
  // (stylesheet is treated as a literal result element stylesheet)
  Object srcObj = mgr.lookupBean ("xslt:src");
  Object xis = null;
  if (srcObj != null) {
            if (srcObj instanceof Node) {
    xis = new DOMSource((Node)srcObj);
            } else {
    try {
                    String mesg = "as anything";
                    if (srcObj instanceof Reader) {
      xis = new StreamSource ((Reader) srcObj);
      mesg = "as a Reader";
                    } else if (srcObj instanceof File) {
                        xis = new StreamSource ((File) srcObj);
                        mesg = "as a file";
                    } else {
                        String srcObjstr=srcObj.toString();
                        xis = new StreamSource (new StringReader(srcObjstr));
                        if (srcObj instanceof URL) {
                            mesg = "as a URL";
                        } else {
                            ((StreamSource) xis).setPublicId (srcObjstr);
                            mesg = "as an XML string";
                        }
                    }

                    if (xis == null) {
      throw new Exception ("Unable to get input from '" +
                                             srcObj + "' " + mesg);
                    }
    } catch (Exception e) {
                    throw new BSFException (BSFException.REASON_EXECUTION_ERROR,
                                            "BSF:XSLTEngine: unable to get " +
                                            "input from '" + srcObj + "' as XML", e);
    }
            }
  } else {
            // create an empty document - real src must come into the
            // stylesheet using "doc(...)" [see XSLT spec] or the stylesheet
            // must be of literal result element type
            xis = new StreamSource();
  }
 
  // set all declared beans as parameters.
  for (int i = 0; i < declaredBeans.size (); i++) {
            BSFDeclaredBean b = (BSFDeclaredBean) declaredBeans.elementAt (i);
            transformer.setParameter (b.name, new XObject (b.bean));
  }

  // declare a "bsf" parameter which is the BSF handle so that
  // the script can do BSF stuff if it wants to
  transformer.setParameter ("bsf",
                                  new XObject (new BSFFunctions (mgr, this)));

  // do it
  try {
            DOMResult result = new DOMResult();
            transformer.transform ((StreamSource) xis, result);
            return new XSLTResultNode (result.getNode());
  } catch (Exception e) {
            throw new BSFException (BSFException.REASON_EXECUTION_ERROR,
                                    "exception while eval'ing XSLT script" + e, e);
  }
    }
View Full Code Here

   * 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);
  }
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.