Package org.mozilla.javascript

Examples of org.mozilla.javascript.ImporterTopLevel


            reader = pReader;
            store = pStore;

            final Context context = Context.enter();
            scope = new ImporterTopLevel(context);
            Context.exit();
        }
View Full Code Here


        try {

            // init std object with an importer
            // building the importer automatically initialize the
            // context with it since Rhino1.5R3
            ImporterTopLevel importer = new ImporterTopLevel(ctx);
            globalObject = importer;
            // import Java lang package & DOM Level 2 & SVG DOM packages
            NativeJavaPackage[] p= new NativeJavaPackage[TO_BE_IMPORTED.length];
            for (int i = 0; i < TO_BE_IMPORTED.length; i++) {
                p[i] = new NativeJavaPackage(TO_BE_IMPORTED[i]);
            }
            importer.importPackage(ctx, globalObject, p, null);
            ctx.setWrapHandler(wrapHandler);
        } finally {
            Context.exit();
        }
    }
View Full Code Here

            }
        };
        cx = Context.enter(cx);

        try {
            Scriptable scope = new ImporterTopLevel(cx);
            scope.put("parent", scope, parentContainer);
            scope.put("assemblyScope", scope, assemblyScope);
            ImporterTopLevel.importPackage(cx,
                    scope, new NativeJavaPackage[]{
                        new NativeJavaPackage("org.picocontainer.defaults", loader),
                        new NativeJavaPackage("org.nanocontainer", loader),
                        new NativeJavaPackage("org.nanocontainer.reflection", loader),
                        // File, URL and URLClassLoader will be frequently used by scripts.
                        new NativeJavaPackage("java.net", loader),
                        new NativeJavaPackage("java.io", loader),
                    },
                    null);
            Script scriptObject = cx.compileReader(scope, getScriptReader(), "javascript", 1, null);
            scriptObject.exec(cx, scope);
            Object pico = scope.get("pico", scope);

            if (pico == null) {
                throw new NanoContainerMarkupException("The script must define a variable named 'pico'");
            }
            if (!(pico instanceof NativeJavaObject)) {
View Full Code Here

    }

    public void initialize() throws Exception {
        Context context = Context.enter();
        try {
            global = new ImporterTopLevel(context);
            global.put("page", global, Context.toObject(this, global));
            global.put("logger", global, Context.toObject(getLogger(), global));
            global.put("xspAttr", global, Context.toObject(new AttributesImpl(), global));

            context.setOptimizationLevel(-1);
View Full Code Here

                /* The ImporterTopLevel ensures that importClass and
                   importPackage statements work in Javascript scripts
                   Make the XScriptContext available as a global variable
                   to the script
                 */
                ImporterTopLevel scope = new ImporterTopLevel(ctxt);

                Scriptable jsCtxt = Context.toObject(
                   ScriptContext.createContext(
                       m_xModel, m_xInvocContext, m_xContext,
                       m_xMultiComponentFactory), scope);
                scope.put("XSCRIPTCONTEXT", scope, jsCtxt);

                Scriptable jsArgs = Context.toObject(params, scope);
                scope.put("ARGUMENTS", scope, jsArgs);

                result = ctxt.evaluateString(scope,
                        source, "<stdin>", 1, null);
                result = ctxt.toString(result);
        return result;
View Full Code Here

       
    }
    private Scriptable getScope(XScriptContext xsctxt )
    {
        Context ctxt = Context.enter();
        ImporterTopLevel scope = new ImporterTopLevel(ctxt);

        Scriptable jsCtxt = Context.toObject(xsctxt, scope);
        scope.put("XSCRIPTCONTEXT", scope, jsCtxt);

        Scriptable jsArgs = Context.toObject(
           new Object[0], scope);
        scope.put("ARGUMENTS", scope, jsArgs);

        Context.exit();
        return scope;
    }
View Full Code Here

        super.initialize(mgr, lang, declaredBeans);

        // Initialize context and global scope object
        try {
            Context cx = Context.enter();
            global = new ImporterTopLevel(cx);
            Scriptable bsf = Context.toObject(new BSFFunctions(mgr, this), global);
            global.put("bsf", global, bsf);

            for(
                @SuppressWarnings("unchecked")
View Full Code Here

            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

            } else {

                // create the request top scope, use the ImporterToplevel here
                // to support the importPackage and importClasses functions
                scope = new ImporterTopLevel(); // new NativeObject();

                // Set the global scope to be our prototype
                scope.setPrototype(rootScope);

                // We want "scope" to be a new top-level scope, so set its
View Full Code Here

    public RhinoInterpreter() {
        // entering a context
        context = Context.enter();
        try {
            // init std object with an importer
            ImporterTopLevel importer = new ImporterTopLevel(context);
            globalObject = (ScriptableObject)context.initStandardObjects(importer);
            // import Java lang package & DOM Level 2 & SVG DOM packages
            NativeJavaPackage[] p= new NativeJavaPackage[TO_BE_IMPORTED.length];
            for (int i = 0; i < TO_BE_IMPORTED.length; i++) {
                p[i] = new NativeJavaPackage(TO_BE_IMPORTED[i]);
            }
            importer.importPackage(context, globalObject, p, null);
            context.setWrapHandler(new EventTargetWrapHandler(this));
        } finally {
            Context.exit();
        }
    }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ImporterTopLevel

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.