Package org.apache.bsf

Examples of org.apache.bsf.BSFManager


    {
        boolean debug = LOG.isDebugEnabled();

        long startTime = debug ? System.currentTimeMillis() : 0;

        BSFManager bsf = obtainBSFManager(cycle);

        ILocation location = getLocation();

        try
        {
            IPage page = cycle.getPage();

            bsf.declareBean("component", _component, _component.getClass());
            bsf.declareBean("page", page, page.getClass());
            bsf.declareBean("cycle", cycle, cycle.getClass());

            bsf.exec(
                _language,
                location.getResourceLocation().toString(),
                location.getLineNumber(),
                location.getLineNumber(),
                _script);
View Full Code Here


    private BSFManager obtainBSFManager(IRequestCycle cycle)
    {
        IEngine engine = cycle.getEngine();
        Pool pool = engine.getPool();

        BSFManager result = (BSFManager) pool.retrieve(BSF_POOL_KEY);

        if (result == null)
        {
            LOG.debug("Creating new BSFManager instance.");

            result = new BSFManager();

            result.setClassLoader(engine.getResourceResolver().getClassLoader());
        }

        return result;
    }
View Full Code Here

    private static final Logger log = LoggingManager.getLoggerForClass();

    private static final long serialVersionUID = 234L;

    public void sampleOccurred(SampleEvent event) {
        BSFManager mgr =null;
        try {
            mgr = getManager();
            if (mgr == null) {
                log.error("Problem creating BSF manager");
                return;
            }
            mgr.declareBean("sampleEvent", event, SampleEvent.class);
            SampleResult result = event.getResult();
            mgr.declareBean("sampleResult", result, SampleResult.class);
            processFileOrScript(mgr);
        } catch (BSFException e) {
            log.warn("Problem in BSF script "+e);
        } finally {
            if (mgr != null) {
                mgr.terminate();
            }
        }
    }
View Full Code Here

    private static final long serialVersionUID = 4;

    /** {@inheritDoc} */
    public long delay() {
        long delay = 0;
        BSFManager mgr = null;
        try {
            mgr = getManager();
            Object o = evalFileOrScript(mgr);
            if (o == null) {
                log.warn("Script did not return a value");
                return 0;
            }
            delay = Long.valueOf(o.toString()).longValue();
        } catch (NumberFormatException e) {
            log.warn("Problem in BSF script "+e);
        } catch (BSFException e) {
            log.warn("Problem in BSF script "+e);
        } finally {
            if(mgr != null) {
                mgr.terminate();
            }
        }
        return delay;
    }
View Full Code Here

    private static final Logger log = LoggingManager.getLoggerForClass();

    private static final long serialVersionUID = 232L;

    public void process(){
        BSFManager mgr =null;
        try {
            mgr = getManager();
            if (mgr == null) { return; }
            processFileOrScript(mgr);
        } catch (BSFException e) {
            log.warn("Problem in BSF script "+e);
        } finally {
            if (mgr != null) {
                mgr.terminate();
            }
        }
    }
View Full Code Here

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

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

   
    private static final long serialVersionUID = 234L;
   
    public void sampleOccurred(SampleEvent event) {
        try {
            BSFManager mgr = getManager();
            if (mgr == null) {
                log.error("Problem creating BSF manager");
                return;
            }
            mgr.declareBean("sampleEvent", event, SampleEvent.class);
            SampleResult result = event.getResult();
            mgr.declareBean("sampleResult", result, SampleResult.class);
            processFileOrScript(mgr);
            mgr.terminate();
        } catch (BSFException e) {
            log.warn("Problem in BSF script "+e);
        }
    }
View Full Code Here

    private static final long serialVersionUID = 232L;

    public void process(){
        try {
            BSFManager mgr = getManager();
            if (mgr == null) { return; }
            processFileOrScript(mgr);
            mgr.terminate();
        } catch (BSFException e) {
            log.warn("Problem in BSF script "+e);
        }
    }
View Full Code Here

    private static final long serialVersionUID = 234L;
   
    public AssertionResult getResult(SampleResult response) {
        AssertionResult result = new AssertionResult(getName());
        try {
            BSFManager mgr = getManager();
            if (mgr == null) {
                result.setFailure(true);
                result.setError(true);
                result.setFailureMessage("BSF Manager not found");
                return result;
            }
            mgr.declareBean("SampleResult", response, SampleResult.class);
            mgr.declareBean("AssertionResult", result, AssertionResult.class);
            processFileOrScript(mgr);
            mgr.terminate();
            result.setError(false);
        } catch (BSFException e) {
            log.warn("Problem in BSF script "+e);
            result.setError(true);
            result.setFailureMessage(e.toString());
View Full Code Here

TOP

Related Classes of org.apache.bsf.BSFManager

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.