Examples of Scriptable


Examples of org.mozilla.javascript.Scriptable

     * Get a node wrapper for a node that may not have been fetched yet
     * @param handle a node handle
     * @return a wrapper for the node
     */
    public Scriptable getNodeWrapper(NodeHandle handle) {
        Scriptable hobj = (HopObject) wrappercache.get(handle);
        if (hobj != null) {
            return hobj;
        } else if (handle.hasNode()) {
            hobj = getNodeWrapper(handle.getNode(app.getWrappedNodeManager()));
        }

        if (hobj == null) {
            String protoName = handle.getKey().getStorageName();
            Scriptable op = getValidPrototype(protoName);

            // no prototype found for this node
            if (op == null) {
                protoName = "HopObject";
                op = getValidPrototype("HopObject");
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

                if (proto != null) {
                    skin = eng.getSkin(proto.getName(), hrefSkin);
                }

                if (skin != null) {
                    Scriptable param = Context.getCurrentContext().newObject(global);
                    param.put("path", param, href);
                    href = skin.renderAsString(eng.getRequestEvaluator(), handler, param).trim();
                    break;
                }

                handler = app.getParentElement(handler);
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        app.setCurrentCodeResource(code);

        String encoding = app.getProperty("sourceCharset");

        try {
            Scriptable op = type.objProto;
            // do the update, evaluating the file
            if (sourceName.endsWith(".js")) {
                reader = encoding == null ?
                        new InputStreamReader(code.getInputStream()) :
                        new InputStreamReader(code.getInputStream(), encoding);
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        String scriptStr = sb.toString();

        Context cx = Context.enter();
        boolean providerFound = false;
        try {
            Scriptable scriptScope = cx.initStandardObjects(null, true);
            Object[] ids = compileScript(cx, scriptStr, scriptScope, f);
            if (ids.length > 0) {
                Service.Mode mode = Service.Mode.PAYLOAD;
                for (Object idObj : ids) {
                    if (!(idObj instanceof String)) {
                        continue;
                    }
                    String id = (String)idObj;
                    if (!id.startsWith("WebServiceProvider")) {
                        continue;
                    }
                    Object obj = scriptScope.get(id, scriptScope);
                    if (!(obj instanceof Scriptable)) {
                        continue;
                    }
                    Scriptable wspVar = (Scriptable)obj;
                    providerFound = true;
                    obj = wspVar.get("ServiceMode", wspVar);
                    if (obj != Scriptable.NOT_FOUND) {
                        if (obj instanceof String) {
                            String value = (String)obj;
                            if ("PAYLOAD".equalsIgnoreCase(value)) {
                                mode = Service.Mode.PAYLOAD;
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

    public DOMSource invoke(DOMSource request) {
        DOMSource response = new DOMSource();
        Context cx = Context.enter();
        try {
            Scriptable scope = cx.newObject(scriptScope);
            scope.setPrototype(scriptScope);
            scope.setParentScope(null);
            Node node = request.getNode();
            Object inDoc = null;
            if (isE4X) {
                try {
                    Object xo = XmlObject.Factory.parse(node);
                    inDoc = Context.toObject(xo, scope);
                    Object[] args = {inDoc};
                    inDoc = cx.newObject(scriptScope, "XML", args);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                inDoc = Context.toObject(node, scope);
            }
            Object[] args = {inDoc};
            Object jsResp = invokeFunc.call(cx, scope, scope, args);
            if (isE4X) {
                // need to check return type and throw exception
                // if wrong type
                Scriptable s = (Scriptable)jsResp;
                Object out = ScriptableObject.callMethod(s,
                                                         "getXmlObject",
                                                         Context.emptyArgs);
                Wrapper wrapped = (Wrapper)out;
                XmlObject xml = (XmlObject)wrapped.unwrap();
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

    }

    try
    {
      final Context context = Context.enter();
      final Scriptable scope = context.initStandardObjects();
      initializeScope(scope);

      return context.evaluateString(scope, expression, getName(), 1, null);
    }
    finally
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        boolean result = false;

        // now evaluate the condition using JavaScript
        Context cx = Context.enter();
        try {
            Scriptable scope = cx.initStandardObjects(null);
            Object cxResultObject = cx.evaluateString(scope, cond
            /** * conditionString ** */
            , "<cmd>", 1, null);
            resultStr = Context.toString(cxResultObject);

View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        String resultStr = "";

        Context cx = Context.enter();
        try {

            Scriptable scope = cx.initStandardObjects(null);

            // Set up some objects for the script to play with
            scope.put("log", scope, log); //$NON-NLS-1$
            scope.put("ctx", scope, jmctx); //$NON-NLS-1$
            scope.put("vars", scope, vars); //$NON-NLS-1$
            scope.put("props", scope, JMeterUtils.getJMeterProperties()); //$NON-NLS-1$
            // Previously mis-spelt as theadName
            scope.put("threadName", 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
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

        if (rootScope == null) {

            final Context rhinoContext = Context.enter();
            try {

                Scriptable tmpScope = rhinoContext.initStandardObjects(
                    new ImporterTopLevel(), false);

                // default classes
                addHostObjects(tmpScope,
                    (Class<? extends ScriptableObject>[]) HOSTOBJECT_CLASSES);
View Full Code Here

Examples of org.mozilla.javascript.Scriptable

                    } else {

                        // but other Scriptable host objects need to be
                        // registered as well
                        final Scriptable host = clazz.newInstance();
                        getWrapFactory().registerWrapper(
                            host.getClass(), host.getClassName());

                    }

                } catch (Throwable t) {
                    log.warn("addHostObjects: Cannot prepare host object "
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.