Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.evaluateString()


                logger.debug("adding object: " + key);
                ScriptableObject.putProperty(scope, key, obj);
            }
           
            logger.debug("evaluating");
            res = ctx.evaluateString(scope, script, "<script>", 1, null);
            logger.trace("res: " + res);

            logger.debug("exiting script context");
            Context.exit();
        }
View Full Code Here


        // LK - these functions are assumed by a lot of code so let's
        //      make them available
        // define "print" function in the new scope
        Context cx = enterContext();
        try {
            cx.evaluateString(newScope, printSource, "print", 1, null);
            requireBuilder.createRequire(cx, newScope).install(newScope);
        } finally {
            Context.exit();
        }
       
View Full Code Here

      scope.put("props", scope, JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
      scope.put("theadName", scope, Thread.currentThread().getName()); //$NON-NLS-1$
      scope.put("sampler", scope, currentSampler); //$NON-NLS-1$
      scope.put("sampleResult", scope, previousResult); //$NON-NLS-1$

            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null); //$NON-NLS-1$

      resultStr = Context.toString(result);
      if (varName != null && vars != null) {// vars can be null if run from TestPlan
        vars.put(varName, resultStr);
            }
View Full Code Here

           ? myProcess.jsScope() : exceptionScope());
    Scriptable scope = cx.newObject (proto);       
    scope.setPrototype (proto);
    scope.setParentScope (null);
   
    Object res = cx.evaluateString (scope, trans.condition(),
            "<condition>", 1, null);
    if (!(res instanceof Boolean)) {
        logger.error
      ("Evaluating transition condition \""+trans.condition()
       + "\" does not yield a boolean result.");
View Full Code Here

            cx.putThreadLocal(MashupConstants.AXIS2_SERVICE, service);
            Scriptable scope = cx.initStandardObjects();
            ScriptableObject.defineClass(scope, ResourceHostObject.class);
            ScriptableObject.defineClass(scope, CollectionHostObject.class);
            ScriptableObject.defineClass(scope, RegistryHostObject.class);
            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null);
            if (result != null && log.isInfoEnabled()) {
                log.info("JavaScript Result: " + Context.toString(result));
            }
        } catch (IllegalAccessException e) {
            log.error("Unable to defining registry host objects.", e);
View Full Code Here

            cx.putThreadLocal(MashupConstants.AXIS2_SERVICE, service);
            Scriptable scope = cx.initStandardObjects();
            ScriptableObject.defineClass(scope, ResourceHostObject.class);
            ScriptableObject.defineClass(scope, CollectionHostObject.class);
            ScriptableObject.defineClass(scope, RegistryHostObject.class);
            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null);
            if (result != null && log.isInfoEnabled()) {
                log.debug("JavaScript Result: " + Context.toString(result));
            }
        } catch (IllegalAccessException e) {
            log.error("Unable to defining registry host objects.", e);
View Full Code Here

            cx.putThreadLocal(MashupConstants.AXIS2_SERVICE, service);
            Scriptable scope = cx.initStandardObjects();
            ScriptableObject.defineClass(scope, ResourceHostObject.class);
            ScriptableObject.defineClass(scope, CollectionHostObject.class);
            ScriptableObject.defineClass(scope, RegistryHostObject.class);
            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null);
            if (result != null && log.isInfoEnabled()) {
                log.info("JavaScript Result: " + Context.toString(result));
            }
        } catch (IllegalAccessException e) {
            log.error("Unable to defining registry host objects.", e);
View Full Code Here

       
    try {
      Scriptable scope = new TopLevelFunctions(context, ctx, context.getDUDir());
      String source = element.getTextContent();
      VariableDelegator delegator = new VariableDelegator(scope, context, ctx);
      ctx.evaluateString(delegator, source, context.getActivityName(), 1, null);
      delegator.writeVariables();
    } catch (WrappedException e) {
      __logger.warn("Error during JS execution.", e);
      if (e.getWrappedException() instanceof FaultException) {
        throw (FaultException)e.getWrappedException();
View Full Code Here

           
            Object wrappedOut = Context.javaToJS(System.out, scope);
          ScriptableObject.putProperty(scope, "out", wrappedOut);

            // Now evaluate the string we've collected. We'll ignore the result.
            cx.evaluateString(scope, script, "<cmd>", 1, null);

           
            // Call function "f('my arg')" and print its result.
            Object fObj = scope.get(methodName, scope);
            if (!(fObj instanceof Function)) {
View Full Code Here

           
            Object wrappedSystem = Context.javaToJS(systemWrapper, scope);
            ScriptableObject.putProperty(scope, "system", wrappedSystem);

            // Now evaluate the string we've collected. We'll ignore the result.
            cx.evaluateString(scope, script, "<cmd>", 1, null);

           
            // Call function "f('my arg')" and print its result.
            Object fObj = scope.get(methodName, scope);
            if (!(fObj instanceof Function)) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.