Package org.mozilla.javascript

Examples of org.mozilla.javascript.NativeJavaPackage$TopLevelPackage


        public void setupPackages(ClassLoader cl) throws Exception {
            final String JAVA_PACKAGE = "JavaPackage";
            if (classLoader != cl) {
                classLoader = cl;
                Scriptable newPackages = new NativeJavaPackage("", cl);
                newPackages.setParentScope(this);
                newPackages.setPrototype(ScriptableObject.getClassPrototype(this, JAVA_PACKAGE));
                super.put("Packages", this, newPackages);
                for (int i = 0; i < BUILTIN_PACKAGES.length; i++) {
                    String pkgName = BUILTIN_PACKAGES[i];
                    Scriptable pkg = new NativeJavaPackage(pkgName, cl);
                    pkg.setParentScope(this);
                    pkg.setPrototype(ScriptableObject.getClassPrototype(this, JAVA_PACKAGE));
                    super.put(pkgName, this, pkg);
                }
            }
        }
View Full Code Here


            Context.enter();
            try {
                final String JAVA_PACKAGE = "JavaPackage";
                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                // FIXME - NativeJavaPackage is an internal class which we should not use
                Scriptable newPackages = new NativeJavaPackage( "", cl );
                newPackages.setParentScope( getScope() );
                newPackages.setPrototype( ScriptableObject.getClassPrototype(   getScope(),
                                                                                JAVA_PACKAGE ) );
                objectModel.put( "Packages", newPackages );
                objectModel.put( "java", ScriptableObject.getProperty( getScope(), "java" ) );
            } finally {
                Context.exit();
View Full Code Here

            WindowWrapper wWrapper = new WindowWrapper(ctx);
            globalObject = wWrapper;
            // 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]);
            } try {
        ScriptableObject.callMethod(globalObject, "importPackage", p);
      } catch (JavaScriptException e) {
        // cannot happen as we know the method is there and
        // the parameters are ok
View Full Code Here

        public void setupPackages(ClassLoader cl) throws Exception {
            final String JAVA_PACKAGE = "JavaPackage";
            if (classLoader != cl) {
                classLoader = cl;
                Scriptable newPackages = new NativeJavaPackage("", cl);
                newPackages.setParentScope(this);
                newPackages.setPrototype(ScriptableObject.getClassPrototype(this, JAVA_PACKAGE));
                super.put("Packages", this, newPackages);
                for (int i = 0; i < BUILTIN_PACKAGES.length; i++) {
                    String pkgName = BUILTIN_PACKAGES[i];
                    Scriptable pkg = new NativeJavaPackage(pkgName, cl);
                    pkg.setParentScope(this);
                    pkg.setPrototype(ScriptableObject.getClassPrototype(this, JAVA_PACKAGE));
                    super.put(pkgName, this, pkg);
                }
            }
        }
View Full Code Here

            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

            WindowWrapper wWrapper = new WindowWrapper(ctx);
            globalObject = wWrapper;
            // 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], rhinoClassLoader);
            } try {
              ScriptableObject.callMethod(globalObject, "importPackage", p);
            } catch (JavaScriptException e) {
              // cannot happen as we know the method is there and
              // the parameters are ok
View Full Code Here

        context = Context.enter();
        // init std object with an importer
        ImporterTopLevel importer = new ImporterTopLevel();
        scope = context.initStandardObjects(importer);
        // import Java lang package & DOM Level 2 & SVG DOM packages
        NativeJavaPackage[] p={new NativeJavaPackage("java.lang"),
                               new NativeJavaPackage("org.w3c.dom"),
                               new NativeJavaPackage("org.w3c.dom.css"),
                               new NativeJavaPackage("org.w3c.dom.events"),
                               new NativeJavaPackage("org.w3c.dom.smil"),
                               new NativeJavaPackage("org.w3c.dom.stylesheets"),
                               new NativeJavaPackage("org.w3c.dom.svg"),
                               new NativeJavaPackage("org.w3c.dom.views")};
        importer.importPackage(context, scope, p, null);
        context.setWrapHandler(new EventTargetWrapHandler(this));
        Context.exit();
    }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeJavaPackage$TopLevelPackage

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.