Package org.apache.bsf

Examples of org.apache.bsf.BSFEngine


            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);
View Full Code Here


      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);
    }
  }
View Full Code Here

            return manager;
        }
        BSFManager m = new BSFManager();
        m.setClassLoader(getScriptClassLoader());
        if (getKeepEngine()) {
            BSFEngine e = manager.loadScriptingEngine(getLanguage());
            this.manager = m;
            this.engine  = e;
        }
        return m;
    }
View Full Code Here

      JMeterContext jmctx = JMeterContextService.getContext();
      JMeterVariables vars = jmctx.getVariables();
      mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$
      mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$

      BSFEngine bsfEngine = mgr.loadScriptingEngine(getScriptLanguage());

      Object bsfOut = null;
      if (fileName.length()>0) {
        res.setSamplerData("File: "+fileName);
        is = new FileInputStream(fileName);
        bsfOut = bsfEngine.eval(fileName, 0, 0, IOUtils.toString(is));
      } else {
        res.setSamplerData("[script]");
          bsfOut = bsfEngine.eval("script", 0, 0, request);
      }

      if (bsfOut != null) {
          res.setResponseData(bsfOut.toString().getBytes());
      }
View Full Code Here

public class BSF implements Script {
    public Object run(String language, String name, String scriptStr, String methodName, Object[] argValues)
            throws Exception {
        BSFManager manager = new BSFManager();
        BSFEngine engine = manager.loadScriptingEngine(language);

        manager.exec(language, "service script for '" +
                name + "'", 0, 0, scriptStr);

        Object result = engine.call(null, methodName, argValues);
        return result;
    }
View Full Code Here

            return manager;
        }
        BSFManager m = new BSFManager();
        m.setClassLoader(getScriptClassLoader());
        if (getKeepEngine()) {
            BSFEngine e = manager.loadScriptingEngine(getLanguage());
            this.manager = m;
            this.engine  = e;
        }
        return m;
    }
View Full Code Here

      JMeterContext jmctx = JMeterContextService.getContext();
      JMeterVariables vars = jmctx.getVariables();
      mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$
      mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$

      BSFEngine bsfEngine = mgr.loadScriptingEngine(getScriptLanguage());

      Object bsfOut = null;
      if (fileName.length()>0) {
        res.setSamplerData("File: "+fileName);
        is = new FileInputStream(fileName);
        bsfOut = bsfEngine.eval(fileName, 0, 0, IOUtils.toString(is));
      } else {
        res.setSamplerData("[script]");
          bsfOut = bsfEngine.eval("script", 0, 0, request);
      }

      if (bsfOut != null) {
          res.setResponseData(bsfOut.toString().getBytes());
      }
View Full Code Here

    @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[]
    }
View Full Code Here

        answer = manager.eval("groovy", "Test1.groovy", 0, 0, "abc");
        assertNull("Undeclared beans should yield null", answer);
    }

    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);
    }
View Full Code Here

        manager = new BSFManager();
    }

    public void testVersion() throws Exception {
        //System.out.println("BSFManager.getVersion() = " + BSFManager.getVersion());
        BSFEngine bsfEngine = manager.loadScriptingEngine("groovy");
        assertEquals(CACHING_ENGINE, bsfEngine.getClass());
    }
View Full Code Here

TOP

Related Classes of org.apache.bsf.BSFEngine

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.