Package org.mozilla.javascript

Examples of org.mozilla.javascript.Function


                    args = parameters;
                } else {
                    args = new Object[0];
                }

                Function function = (Function) jsFunction;
                function.call(jsEngine.getCx(), jsEngine, jsEngine, args);

            } else if (jsFunction instanceof String) {
                String jsString = (String) jsFunction;
                jsEngine.getCx()
                        .evaluateString(jsEngine, jsString, "Load JavaScriptString", 0, null);
View Full Code Here


                If a mashup had specified a function to be called on undeployment
                (Service LifeCycle support) we need to call it on service undeployment.
                The deployer adds a parameter to the axisService specifying which function to
                call on undeployment if such a function was specified.
                */
                Function destroy =
                        (Function) service.getParameterValue(JSConstants.MASHUP_DESTROY_FUNCTION);
                if (destroy != null) {
                    JavaScriptEngine engine = new JavaScriptEngine(jsFileName);
                    JavaScriptEngineUtils.loadHostObjects(engine, jsFilePath);
                    destroy.call(engine.getCx(), engine, engine, new Object[0]);
                }
            }

            /*
            There exist only one service group for the JavaScript services deployed from this
View Full Code Here

                            schemaGenerator, targetNamespace);
                }
            }
            axisService.addSchema(schemaGenerator.getSchema());

            Function init = serviceAnnotationParser.getInit();
            Function destroy = serviceAnnotationParser.getDestroy();

            /*
            this.init and this.destroy correspond to service lifecycle functions.
            this.init is called upon service deployment and this.destroy is called on
            undeployment.
View Full Code Here

            throw new DeploymentException("Method " + "org_wso2_mashup_ConvertToString" +
                    " is undefined or not a function");
        }

        Object functionArgs[] = {};
        Function f = (Function) fObj;

        // Execute our org_wso2_mashup_ConvertToString function and get the function a string
        Object args = f.call(engine.getCx(), engine, engine, functionArgs);
        String[] params = null;
        if (args instanceof String) {
            String functionString = (String) args;
            int paramStartIndex = functionString.indexOf('(');
            int paramEndIndex = functionString.indexOf(')');
View Full Code Here

            // Call function "f('my arg')" and print its result.
            Object fObj = scope.get(methodName, scope);
            if (!(fObj instanceof Function)) {
                System.out.println("f is undefined or not a function.");
            } else {
                Function f = (Function)fObj;
                Object result = f.call(cx, scope, scope, args);
                String report = "f('my args') = " + Context.toString(result);
                System.out.println(report);
            }
        } finally {
            Context.exit();
View Full Code Here

            // Call function "f('my arg')" and print its result.
            Object fObj = scope.get(methodName, scope);
            if (!(fObj instanceof Function)) {
                System.out.println("f is undefined or not a function.");
            } else {
                Function f = (Function)fObj;
                Object result = f.call(cx, scope, scope, args);
                //String report = "f('my args') = " + Context.toString(result);
                //System.out.println(report);
            }
        } finally {
            Context.exit();
View Full Code Here

            if (!(fObj instanceof Function) || (fObj == Scriptable.NOT_FOUND)) {
                throw new AxisFault("Method " + method + " is undefined or not a function");
            }
            // Invokes the java script function

            Function f = (Function) fObj;
            return f.call(cx, this, this, functionArgs);
        } catch (WrappedException exception) {
            throw AxisFault.makeFault(exception.getCause());
        } catch (JavaScriptException exception) {
            throw new AxisFault(exception.getValue().toString(), exception);
        } catch (Throwable throwable) {
View Full Code Here

    }

    public Object evaluateFunction(String func, Object[] args) {
        func = "var x = " + func + ";";
        this.cx.evaluateString(this, func, "Eval Func", 0, null);
        Function function = (Function) this.get("x", this);
        return function.call(this.cx, this, this, args);
    }
View Full Code Here

    private void notifyAddRow() {
        ScriptableWidget repeater = wrap(delegate.getParent());
        Object prop = getProperty(repeater, "onAddRow");
        if (prop instanceof Function) {
            try {
                Function fun = (Function)prop;
                Object[] args = new Object[1];
                Scriptable scope = getTopLevelScope(this);
                Scriptable thisObj = scope;
                Context cx = Context.getCurrentContext();
                args[0] = this;
                fun.call(cx, scope, thisObj, args);
            } catch (Exception exc) {
                throw Context.reportRuntimeError(exc.getMessage());
            }
        }
    }
View Full Code Here

    private void notifyRemoveRow() {
        ScriptableWidget repeater = wrap(delegate.getParent());
        Object prop = getProperty(repeater, "onRemoveRow");
        if (prop instanceof Function) {
            try {
                Function fun = (Function)prop;
                Object[] args = new Object[1];
                Scriptable scope = getTopLevelScope(this);
                Scriptable thisObj = scope;
                Context cx = Context.getCurrentContext();
                args[0] = this;
                fun.call(cx, scope, thisObj, args);
            } catch (Exception exc) {
                throw Context.reportRuntimeError(exc.getMessage());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Function

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.