Package org.mozilla.javascript

Examples of org.mozilla.javascript.ContextFactory$GlobalSetter


    private void dropRootScope() {

        // ensure the debugger is closed if the root scope will
        // be replaced to ensure no references to the old scope
        // and context remain
        ContextFactory contextFactory = ContextFactory.getGlobal();
        if (contextFactory instanceof SlingContextFactory) {
            ((SlingContextFactory) contextFactory).exitDebugger();
        }

        // drop the scope
View Full Code Here


        setExtensions(ECMA_SCRIPT_EXTENSION, ESP_SCRIPT_EXTENSION);
        setMimeTypes("text/javascript", "application/ecmascript",
            "application/javascript");
        setNames("javascript", ECMA_SCRIPT_EXTENSION, ESP_SCRIPT_EXTENSION);

        final ContextFactory contextFactory = ContextFactory.getGlobal();
        if (contextFactory instanceof SlingContextFactory) {
            ((SlingContextFactory) contextFactory).setDebugging(debugging);
        }
        // set the dynamic class loader as the application class loader
        final DynamicClassLoaderManager dclm = this.dynamicClassLoaderManager;
        if ( dclm != null ) {
            contextFactory.initApplicationClassLoader(dynamicClassLoaderManager.getDynamicClassLoader());
        }
       
        log.info("Activated with optimization level {}", optimizationLevel);
    }
View Full Code Here

        super(classpathReference);
    }

    public void initializeRhino() {

        rhinoContextFactory = new ContextFactory();
        if (System.getProperty("cxf.jsdebug") != null && !rhinoDebuggerUp) {
            try {
                Class<?> debuggerMain =
                            ClassLoaderUtils.loadClass("org.mozilla.javascript.tools.debugger.Main",
                                                                   getClass());
View Full Code Here

        assertTrue("success".equals(result));
        System.out.println("passed");
    }
   
    public void runJsTests(File[] tests) throws IOException {
        ContextFactory factory = ContextFactory.getGlobal();
        Context cx = factory.enterContext();
        try {
            cx.setOptimizationLevel(this.optimizationLevel);
            Scriptable shared = cx.initStandardObjects();
            for (File f : tests) {
                int length = (int) f.length(); // don't worry about very long
View Full Code Here

    }

    LegacyDataRowWrapper wrapper = null;
    try
    {
      final ContextFactory contextFactory = new ContextFactory();
      final Context context = contextFactory.enterContext();
      final Scriptable scope = context.initStandardObjects();
      wrapper = initializeScope(scope);

      final Object o = context.evaluateString(scope, expression, getName(), 1, null);
      if (o instanceof NativeJavaObject)
View Full Code Here

   *
   * TODO: make the custom classloader work (at not loading all the Java classes).
   */
  @BeforeClass
  public static void messWithClassLoader() {
    ContextFactory.initGlobal(new ContextFactory() {
      @Override
      protected Context makeContext() {
        Context cx = super.makeContext();
        cx.setWrapFactory(new WrapFactory() {
          @Override
          public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
            return super.wrap(cx, scope, obj, staticType);
          }
          @Override
          public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) {
            return super.wrapNewObject(cx, scope, obj);
          }
          @Override
          public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) {
            return new SandboxNativeJavaObject(scope, javaObject, staticType);
          }           
        });
        return cx;
      }       
    });
    ContextFactory factory = ContextFactory.getGlobal();
    factory.initApplicationClassLoader(new SandboxClassLoader(TurtleSpecSection2_2Test.class.getClassLoader()));   
  }
View Full Code Here

   *
   * TODO: make the custom classloader work (at not loading all the Java classes).
   */
  @BeforeClass
  public static void messWithClassLoader() {
    ContextFactory.initGlobal(new ContextFactory() {
      @Override
      protected Context makeContext() {
        Context cx = super.makeContext();
        cx.setWrapFactory(new WrapFactory() {
          @Override
          public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
            return super.wrap(cx, scope, obj, staticType);
          }
          @Override
          public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) {
            return super.wrapNewObject(cx, scope, obj);
          }
          @Override
          public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) {
            return new SandboxNativeJavaObject(scope, javaObject, staticType);
          }           
        });
        return cx;
      }       
    });
    ContextFactory factory = ContextFactory.getGlobal();
    factory.initApplicationClassLoader(new SandboxClassLoader(TurtleSpecSection2_2Test.class.getClassLoader()));   
  }
View Full Code Here

     *
     * TODO: make the custom class loader work (at not loading all the Java classes).
     */
    @BeforeClass
    public static void messWithClassLoader() {
      ContextFactory.initGlobal(new ContextFactory() {
        @Override
        protected Context makeContext() {
          Context cx = super.makeContext();
          cx.setWrapFactory(new WrapFactory() {
            @Override
            public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
              return super.wrap(cx, scope, obj, staticType);
            }
            @Override
            public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) {
              return super.wrapNewObject(cx, scope, obj);
            }
            @Override
            public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) {
              return new SandboxNativeJavaObject(scope, javaObject, staticType);
            }           
          });
          return cx;
        }       
      });
      ContextFactory factory = ContextFactory.getGlobal();
      factory.initApplicationClassLoader(new SandboxClassLoader(TurtleSpecSection2_1Test.class.getClassLoader()));   
    }
View Full Code Here

     *
     * TODO: make the custom class loader work (at not loading all the Java classes).
     */
    @BeforeClass
    public static void messWithClassLoader() {
      ContextFactory.initGlobal(new ContextFactory() {
        @Override
        protected Context makeContext() {
          Context cx = super.makeContext();
          cx.setWrapFactory(new WrapFactory() {
            @Override
            public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
              return super.wrap(cx, scope, obj, staticType);
            }
            @Override
            public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) {
              return super.wrapNewObject(cx, scope, obj);
            }
            @Override
            public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) {
              return new SandboxNativeJavaObject(scope, javaObject, staticType);
            }           
          });
          return cx;
        }       
      });
      ContextFactory factory = ContextFactory.getGlobal();
      factory.initApplicationClassLoader(new SandboxClassLoader(TurtleSpecSection2_1Test.class.getClassLoader()));   
    }
View Full Code Here

   
    public void initialize() {
        if (!initialized) {
            if ("true".equals(getProperty(USE_INTERPRETER_SYSTEM_PROPERTY))) {
                if (!ContextFactory.hasExplicitGlobal()) {
                    ContextFactory.initGlobal(new ContextFactory() {
                        @Override
                        protected Context makeContext() {
                            Context cx = super.makeContext();
                            cx.setOptimizationLevel(-1);
                            return cx;
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ContextFactory$GlobalSetter

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.