当前位置: 首页>>代码示例>>Java>>正文


Java BSFException类代码示例

本文整理汇总了Java中org.apache.bsf.BSFException的典型用法代码示例。如果您正苦于以下问题:Java BSFException类的具体用法?Java BSFException怎么用?Java BSFException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BSFException类属于org.apache.bsf包,在下文中一共展示了BSFException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import org.apache.bsf.BSFException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
    super.initialize(mgr, lang, declaredBeans);

    interpreter = BshUtil.getMasterInterpreter(null);

    // declare the bsf manager for callbacks, etc.
    try {
        interpreter.set("bsf", mgr);
    } catch (EvalError e) {
        throw new BSFException("bsh internal error: "+e.toString());
    }

    for (int i=0; i<declaredBeans.size(); i++) {
        BSFDeclaredBean bean = (BSFDeclaredBean)declaredBeans.get(i);
        declareBean(bean);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:20,代码来源:OfbizBshBsfEngine.java

示例2: invokeBusinessLogic

import org.apache.bsf.BSFException; //导入依赖的package包/类
/**
 * Invokes the service by calling the script function
 */
public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault {
    try {

        log.debug("invoking script service");

        outMC.setEnvelope(getSOAPFactory(inMC).getDefaultEnvelope());

        BSFEngine engine = getBSFEngine(inMC);
        OMElementConvertor convertor = (OMElementConvertor) inMC.getServiceContext().getProperty(CONVERTOR_PROP);

        Parameter scriptFunctionParam = inMC.getAxisService().getParameter(FUNCTION_ATTR);
        String scriptFunction = scriptFunctionParam == null ? DEFAULT_FUNCTION : (String) scriptFunctionParam.getValue();

        ScriptMessageContext inScriptMC = new ScriptMessageContext(inMC, convertor);
        ScriptMessageContext outScriptMC = new ScriptMessageContext(outMC, convertor);
        Object[] args = new Object[] { inScriptMC, outScriptMC };

        engine.call(null, scriptFunction, args);

    } catch (BSFException e) {
        throw AxisFault.makeFault(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:ScriptReceiver.java

示例3: addPetData

import org.apache.bsf.BSFException; //导入依赖的package包/类
public void addPetData(BSFManager context, int petID, int levelStart, int levelEnd, Map<String, String> stats)
throws BSFException
  {
      L2PetData[] petData = new L2PetData[levelEnd - levelStart + 1];
      int value           = 0;
      for (int level = levelStart; level <= levelEnd; level++)
      {
          petData[level - 1]  = new L2PetData();
          petData[level - 1].setPetID(petID);
          petData[level - 1].setPetLevel(level);

       context.declareBean("level", new Double(level), Double.TYPE);
          for (String stat : stats.keySet())
          {
		value = ((Number)Expression.eval(context, "beanshell", stats.get(stat))).intValue();
              petData[level - 1].setStat(stat, value);
          }
       context.undeclareBean("level");
      }

  }
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:22,代码来源:FaenorInterface.java

示例4: parsePackages

import org.apache.bsf.BSFException; //导入依赖的package包/类
public void parsePackages()
{
    BSFManager context = new BSFManager();
    try
    {
        context.eval("beanshell", "core", 0, 0, "double log1p(double d) { return Math.log1p(d); }");
        context.eval("beanshell", "core", 0, 0,
                     "double pow(double d, double p) { return Math.pow(d,p); }");

        for (ScriptDocument script : _scripts)
        {
            parseScript(script, context);
            //System.out.println(script.getName());
        }
    }
    catch (BSFException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:21,代码来源:FaenorScriptEngine.java

示例5: init

import org.apache.bsf.BSFException; //导入依赖的package包/类
/**
 * Initialize the engine for scripts of quests, luxury shops and blacksmith
 */
public static void init()
{
	try
	{
		// Initialize the engine for loading Jython scripts
		_bsf = new BSFManager();
		// Execution of all the scripts placed in data/jscript
		// inside the DataPack directory

		String dataPackDirForwardSlashes = Config.DATAPACK_ROOT.getPath().replaceAll("\\\\","/");
		String loadingScript =
		    "import sys;"
		  + "sys.path.insert(0,'" + dataPackDirForwardSlashes + "');"
		  + "import data";

		_bsf.exec("jython", "quest", 0, 0, loadingScript);
	}
	catch (BSFException e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:26,代码来源:QuestJython.java

示例6: getResult

import org.apache.bsf.BSFException; //导入依赖的package包/类
@Override
public AssertionResult getResult(SampleResult response) {
    AssertionResult result = new AssertionResult(getName());
    BSFManager mgr =null;
    try {
        mgr = getManager();
        mgr.declareBean("SampleResult", response, SampleResult.class);
        mgr.declareBean("AssertionResult", result, AssertionResult.class);
        processFileOrScript(mgr);
        result.setError(false);
    } catch (BSFException e) {
        log.warn("Problem in BSF script "+e);
        result.setFailure(true);
        result.setError(true);
        result.setFailureMessage(e.toString());
    } finally {
        if(mgr != null) {
            mgr.terminate();
        }
    }
    return result;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:BSFAssertion.java

示例7: eval

import org.apache.bsf.BSFException; //导入依赖的package包/类
/**
 * Evaluate an expression.
 */
public Object eval(String source, int lineNo, int columnNo, Object script) throws BSFException {
    try {
        Class scriptClass = evalScripts.get(script);
        if (scriptClass == null) {
            scriptClass = loader.parseClass(script.toString(), source);
            evalScripts.put(script, scriptClass);
        } else {
            LOG.fine("eval() - Using cached script...");
        }
        //can't cache the script because the context may be different.
        //but don't bother loading parsing the class again
        Script s = InvokerHelper.createScript(scriptClass, context);
        return s.run();
    } catch (Exception e) {
        throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "exception from Groovy: " + e, e);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:CachingGroovyEngine.java

示例8: exec

import org.apache.bsf.BSFException; //导入依赖的package包/类
/**
 * Execute a script.
 */
public void exec(String source, int lineNo, int columnNo, Object script) throws BSFException {
    try {
        //          shell.run(script.toString(), source, EMPTY_ARGS);

        Class scriptClass = execScripts.get(script);
        if (scriptClass == null) {
            scriptClass = loader.parseClass(script.toString(), source);
            execScripts.put(script, scriptClass);
        } else {
            LOG.fine("exec() - Using cached version of class...");
        }
        InvokerHelper.invokeMethod(scriptClass, "main", EMPTY_ARGS);
    } catch (Exception e) {
        LOG.log(Level.WARNING, "BSF trace", e);
        throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "exception from Groovy: " + e, e);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:CachingGroovyEngine.java

示例9: initialize

import org.apache.bsf.BSFException; //导入依赖的package包/类
/**
 * Initialize the engine.
 */
public void initialize(final BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
    super.initialize(mgr, lang, declaredBeans);
    ClassLoader parent = mgr.getClassLoader();
    if (parent == null)
        parent = GroovyShell.class.getClassLoader();
    setLoader(mgr, parent);
    execScripts = new HashMap<Object, Class>();
    evalScripts = new HashMap<Object, Class>();
    context = shell.getContext();
    // create a shell
    // register the mgr with object name "bsf"
    context.setVariable("bsf", new BSFFunctions(mgr, this));
    int size = declaredBeans.size();
    for (int i = 0; i < size; i++) {
        declareBean((BSFDeclaredBean) declaredBeans.elementAt(i));
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:CachingGroovyEngine.java

示例10: initialize

import org.apache.bsf.BSFException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
    super.initialize(mgr, lang, declaredBeans);

    interpreter = BshUtil.getMasterInterpreter(null);

    // declare the bsf manager for callbacks, etc.
    try {
        interpreter.set("bsf", mgr);
    } catch (EvalError e) {
        throw new BSFException("bsh internal error: "+e.toString());
    }

    for(int i=0; i<declaredBeans.size(); i++) {
        BSFDeclaredBean bean = (BSFDeclaredBean)declaredBeans.get(i);
        declareBean(bean);
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:20,代码来源:OfbizBshBsfEngine.java

示例11: runScripts

import org.apache.bsf.BSFException; //导入依赖的package包/类
protected void runScripts() {
        if (_bsfManager == null) return;
        synchronized(_bsfManager) {
            for (int i=0; i<_scripts.size(); i++) {
                Script script = _scripts.get(i);
                if (script.isEnabled()) {
//                    if (_scriptManager != null) _scriptManager.scriptStarted(this, script);
                    try {
                        _bsfManager.exec(script.getLanguage(), _name, 0, 0, script.getScript());
                    } catch (BSFException bsfe) {
                        _logger.warning("Script exception: " + bsfe);
//                        if (_scriptManager != null) _scriptManager.scriptError(this, script, bsfe);
                    }
//                    if (_scriptManager != null) _scriptManager.scriptEnded(this, script);
                }
            }
        }
    }
 
开发者ID:Neraud,项目名称:PADListener,代码行数:19,代码来源:Hook.java

示例12: executeScript

import org.apache.bsf.BSFException; //导入依赖的package包/类
/**
 * Do the work.
 *
 * @param execName the name that will be passed to BSF for this script execution.
 * @exception BuildException if something goes wrong executing the script.
 */
@Override
public void executeScript(String execName) throws BuildException {
    checkLanguage();
    ClassLoader origLoader = replaceContextLoader();
    try {
        BSFManager m = createManager();
        declareBeans(m);
        // execute the script
        if (engine == null) {
            m.exec(getLanguage(), execName, 0, 0, getScript());
        } else {
            engine.exec(execName, 0, 0, getScript());
        }
    } catch (BSFException be) {
        throw getBuildException(be);
    } finally {
        restoreContextLoader(origLoader);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:26,代码来源:ScriptRunner.java

示例13: evaluateScript

import org.apache.bsf.BSFException; //导入依赖的package包/类
/**
 * Evaluate the script.
 *
 * @param execName the name that will be passed to BSF for this script execution.
 * @return the result of the evaluation
 * @exception BuildException if something goes wrong executing the script.
 */
@Override
public Object evaluateScript(String execName) throws BuildException {
    checkLanguage();
    ClassLoader origLoader = replaceContextLoader();
    try {
        BSFManager m = createManager();
        declareBeans(m);
        // execute the script
        if (engine == null) {
            return m.eval(getLanguage(), execName, 0, 0, getScript());
        }
        return engine.eval(execName, 0, 0, getScript());
    } catch (BSFException be) {
        throw getBuildException(be);
    } finally {
        restoreContextLoader(origLoader);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:26,代码来源:ScriptRunner.java

示例14: initEngine

import org.apache.bsf.BSFException; //导入依赖的package包/类
protected void initEngine() {
	try {

		String scriptLanguage = BSFManager.getLangFromFilename(scriptName);
		BSFManager bsfManager = new BSFManager();
		bsfManager.setClassLoader(BSFManager.class.getClassLoader());
		// bsfManager.declareBean("_AxisService", axisService,
		// AxisService.class);

		BSFEngine bsfEngine = bsfManager
				.loadScriptingEngine(scriptLanguage);
		Object scriptSrc = readScript();
		bsfEngine.exec(scriptName, 0, 0, scriptSrc);

	} catch (BSFException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:ScriptInvoker.java

示例15: eval

import org.apache.bsf.BSFException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Object eval(String fileName, int lineNo, int colNo, Object expr)
        throws BSFException {
    if (expr == null) {
        return null;
    }
    try {
        Script jExpr = null;
        if (expr instanceof File) {
            jExpr = ScriptFactory.createScript((File) expr);
        } else if (expr instanceof URL) {
            jExpr = ScriptFactory.createScript((URL) expr);
        } else {
            jExpr = ScriptFactory.createScript((String) expr);
        }
        return jExpr.execute(jc);
    } catch (Exception e) {
        throw new BSFException(BSFException.REASON_OTHER_ERROR, e.getMessage(), e);
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:22,代码来源:JexlEngine.java


注:本文中的org.apache.bsf.BSFException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。