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


Java BSFManager.exec方法代码示例

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


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

示例1: init

import org.apache.bsf.BSFManager; //导入方法依赖的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

示例2: executeScript

import org.apache.bsf.BSFManager; //导入方法依赖的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

示例3: start

import org.apache.bsf.BSFManager; //导入方法依赖的package包/类
/**
 * Starts the fiber. If the fiber has already been run or is currently
 * running then an exception is generated. The status of the fiber is
 * updated to <code>STARTING</code> and will transition to <code>
 * RUNNING</code>
 * when the fiber finishes initializing and begins processing the
 * encapsulaed queue.
 *
 * @throws java.lang.IllegalStateException
 *             Thrown if the fiber is stopped or has never run.
 */
public synchronized void start() {
    ThreadCategory log = ThreadCategory.getInstance(Executor.class);

    if (m_worker != null) {
        throw new IllegalStateException("The fiber has already been run");
    }

    m_status = STARTING;

    Engine[] engines = m_config.getEngines();

    for (int i = 0; i < engines.length; i++) {
        Engine engine = engines[i];

        log.debug("Registering engine: " + engine.getLanguage());

        String[] extensions = null;

        String extensionList = engines[i].getExtensions();

        if (extensionList != null) {
            StringTokenizer st = new StringTokenizer(extensionList);

            extensions = new String[st.countTokens()];

            int j = 0;

            while (st.hasMoreTokens()) {
                extensions[j++] = st.nextToken();
            }
        }

        BSFManager.registerScriptingEngine(engines[i].getLanguage(), engines[i].getClassName(), extensions);
    }

    m_mgr = new BSFManager();
    m_mgr.registerBean("log", ThreadCategory.getInstance(Executor.class));

    StartScript[] startScripts = m_config.getStartScripts();

    for (int i = 0; i < startScripts.length; i++) {
        try {
            m_mgr.exec(startScripts[i].getLanguage(), "", 0, 0, startScripts[i].getContent());
        }

        catch (BSFException ex) {
            log.error("Start script[" + i + "] failed.", ex);
        }
    }

    m_worker = new Thread(this, getName());
    m_worker.start();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:65,代码来源:Executor.java


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