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


Java BSFEngine类代码示例

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


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

示例1: invokeBusinessLogic

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

示例2: initEngine

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

示例3: processFileOrScript

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
protected void processFileOrScript(BSFManager mgr) throws BSFException{
    BSFEngine bsfEngine = mgr.loadScriptingEngine(getScriptLanguage());
    final String scriptFile = getFilename();
    if (scriptFile.length() == 0) {
        bsfEngine.exec("[script]",0,0,getScript());
    } else {// we have a file, read and process it
        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);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:16,代码来源:BSFTestElement.java

示例4: evalFileOrScript

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
protected Object evalFileOrScript(BSFManager mgr) throws BSFException{
    BSFEngine bsfEngine = mgr.loadScriptingEngine(getScriptLanguage());
    final String scriptFile = getFilename();
    if (scriptFile.length() == 0) {
        return bsfEngine.eval("[script]",0,0,getScript());
    } else {// we have a file, read and process it
        try {
            String script=FileUtils.readFileToString(new File(scriptFile));
            return bsfEngine.eval(scriptFile,0,0,script);
        } catch (IOException e) {
            log.warn(e.getLocalizedMessage());
            throw new BSFException(BSFException.REASON_IO_ERROR,"Problem reading script file",e);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:16,代码来源:BSFTestElement.java

示例5: testAccess

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
@Test
public void testAccess() throws BSFException {
    // tag::bsf_access[]
    BSFManager manager = new BSFManager();
    BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
    manager.declareBean("myvar", "hello", String.class);
    Object myvar = manager.lookupBean("myvar");
    String result = (String) bsfEngine.call(myvar, "reverse", new Object[0]);
    assertEquals("olleh", result);
    // end::bsf_access[]
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:BSFSpecTest.java

示例6: testCall

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
public void testCall() throws Exception {
    BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
    manager.declareBean("myvar", "hello", String.class);
    Object myvar = manager.lookupBean("myvar");
    String result = (String) bsfEngine.call(myvar, "reverse", new Object[]{});
    assertEquals("olleh", result);
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:BSFTest.java

示例7: createManager

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
private BSFManager createManager() throws BSFException {
    if (manager != null) {
        return manager;
    }
    BSFManager m = new BSFManager();
    m.setClassLoader(getScriptClassLoader());
    if (getKeepEngine()) {
        BSFEngine e = manager.loadScriptingEngine(getLanguage());
        this.manager = m;
        this.engine  = e;
    }
    return m;
}
 
开发者ID:apache,项目名称:ant,代码行数:14,代码来源:ScriptRunner.java

示例8: isMethodDefined

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
public boolean isMethodDefined(String method, String scriptName, BSFEngine engine, BSFManager manager)
        throws BSFException
{
    String script = "this.namespace.getMethod(\"" + method + "\", new Class[0])";
    Object res =
            engine.eval(scriptName, 1, 1, script);
    return res != null;
}
 
开发者ID:OpenNMS,项目名称:installer,代码行数:9,代码来源:BSFAction.java

示例9: testVersion

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
public void testVersion() throws Exception {
    //System.out.println("BSFManager.getVersion() = " + BSFManager.getVersion());
    BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
    assertEquals(CACHING_ENGINE, bsfEngine.getClass());
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:CacheBSFTest.java

示例10: initScript

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
/**
 * Initializes the script service by finding the script source code,
 * compiling it in a BSFEngine, and creating an OMElementConvertor
 * for the script.
 */
protected BSFEngine initScript(MessageContext mc) throws AxisFault {
    log.debug("initializing script service");

    AxisService axisService = mc.getAxisService();

    String scriptName = null;
    String scriptSrc = null;
    Parameter scriptFileParam = axisService.getParameter(SCRIPT_ATTR);
    if (scriptFileParam != null) {
        // the script is defined in a seperate file
        scriptName = ((String) scriptFileParam.getValue()).trim();
        Parameter scriptSrcParam = axisService.getParameter(SCRIPT_SRC_PROP);
        if (scriptSrcParam != null) {
            scriptSrc = (String) scriptSrcParam.getValue();
        } else {
            scriptSrc = readScript(axisService.getClassLoader(), scriptName);
        }
    } else {
        // the script is defined inline within the services.xml
        ArrayList parameters = axisService.getParameters();
        for (int i=0; scriptFileParam == null && i<parameters.size(); i++) {
            Parameter p = (Parameter) parameters.get(i);
            if (p.getName().startsWith("script.")) {
                scriptFileParam = p;
                scriptName = p.getName();
                scriptSrc = (String) p.getValue();
            }
        }
    }
    if (scriptName == null) {
        throw new AxisFault("Missing script parameter");
    }
    
    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);
        bsfEngine.exec(scriptName, 0, 0, scriptSrc);

        ServiceContext serviceContext = mc.getServiceContext();
        serviceContext.setProperty(BSFENGINE_PROP, bsfEngine);

        OMElementConvertor convertor = ConvertorFactory.createOMElementConvertor(axisService, scriptName);
        serviceContext.setProperty(CONVERTOR_PROP, convertor);

        return bsfEngine;

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

示例11: setEngine

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
public void setEngine(BSFEngine e) {
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:3,代码来源:DefaultOMElementConvertor.java

示例12: setEngine

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
public void setEngine(BSFEngine e) {
    this.bsfEngine = e;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:4,代码来源:RBOMElementConvertor.java

示例13: setEngine

import org.apache.bsf.BSFEngine; //导入依赖的package包/类
public void setEngine(BSFEngine e); 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:2,代码来源:OMElementConvertor.java


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