Package org.mule.tools.rhinodo.rhino

Examples of org.mule.tools.rhinodo.rhino.NodeJsGlobal


            final ContextFactory contextFactory,
            final Map<String, String> env,
            final Function callback,
            final boolean debug) {

        final NodeJsGlobal global = new NodeJsGlobal();
        final Main main  = debug ? doDebug(contextFactory, global) : null;

        contextFactory.call(new ContextAction() {
            @Override
            public Object run(Context ctx) {
                ctx.setOptimizationLevel(debug ? -1 : 9);
                ctx.setLanguageVersion(Context.VERSION_1_8);
                global.initStandardObjects(ctx, false);

                if ( debug ) {

                    ScriptableObject.putProperty(global, "strikeThePose", new BaseFunction() {
                        @Override
                        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
                            main.doBreak();
                            return Undefined.instance;
                        }
                    });

                }

                ExitCallbackExecutor exitCallbackExecutor = new ExitCallbackExecutor();

                Scriptable envAsScriptable = mapToScriptable(ctx, global, env);

                Require require = global.installNodeJsRequire(ctx, envAsScriptable, nodeModuleProvider,
                        new NodeRequireBuilder(asyncFunctionQueue, exitCallbackExecutor), false);

                //TODO Get a real buffer here...
                ScriptableObject.putProperty(global, "Buffer", Context.javaToJS(ctx.newObject(global), global));
                Scriptable buffer = (Scriptable) require.call(ctx, global, global, new Object[]{Context.javaToJS("buffer", global)});
View Full Code Here

TOP

Related Classes of org.mule.tools.rhinodo.rhino.NodeJsGlobal

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.