Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.evaluateReader()


      // load the scripts and evaluate them in the Rhino context
      ClassLoader loader = LessFilter.class.getClassLoader();
      for (String script : LESS_JS) {
        URL url = loader.getResource(LESS_PATH + script);
        Reader reader = new InputStreamReader(url.openStream(), "UTF-8");
        context.evaluateReader(this.scope, reader, script, 1, null);
      }
     
      // get environment object and set the resource loader used in less (see less-api.js)
      Scriptable env = (Scriptable) this.scope.get("__env", this.scope);
      env.put("resourceLoader", env, Context.javaToJS(new ResourceLoader(), this.scope));
View Full Code Here


          + cx.getImplementationVersion());
      cx.setOptimizationLevel(-1);
      Global global = new Global();
      global.init(cx);
      scope = cx.initStandardObjects(global);
      cx.evaluateReader(scope, new InputStreamReader(env.openConnection()
          .getInputStream()), env.getFile(), 1, null);
      Scriptable lessEnv = (Scriptable) scope.get("lessenv", scope);
      lessEnv.put("charset", lessEnv, options.getCharset());
      lessEnv.put("css", lessEnv, options.isCss());
      lessEnv.put("lineNumbers", lessEnv, options.getLineNumbers());
View Full Code Here

      lessEnv.put("charset", lessEnv, options.getCharset());
      lessEnv.put("css", lessEnv, options.isCss());
      lessEnv.put("lineNumbers", lessEnv, options.getLineNumbers());
      lessEnv.put("optimization", lessEnv, options.getOptimization());
      lessEnv.put("loader", lessEnv, Context.javaToJS(loader, scope));
      cx.evaluateReader(scope, new InputStreamReader(less
          .openConnection().getInputStream()), less.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(cssmin
          .openConnection().getInputStream()), cssmin.getFile(), 1,
          null);
View Full Code Here

      lessEnv.put("optimization", lessEnv, options.getOptimization());
      lessEnv.put("loader", lessEnv, Context.javaToJS(loader, scope));
      cx.evaluateReader(scope, new InputStreamReader(less
          .openConnection().getInputStream()), less.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(cssmin
          .openConnection().getInputStream()), cssmin.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(engine
          .openConnection().getInputStream()), engine.getFile(), 1,
          null);
View Full Code Here

          .openConnection().getInputStream()), less.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(cssmin
          .openConnection().getInputStream()), cssmin.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(engine
          .openConnection().getInputStream()), engine.getFile(), 1,
          null);
      compile = (Function) scope.get("compile", scope);
      Context.exit();
    } catch (Exception e) {
View Full Code Here

        scope.setParentScope(global);
        scope.setPrototype(global);
        Context cx = enterContext();
        try {
            scope.put("exports", scope, cx.newObject(global));
            result = cx.evaluateReader(scope, reader, filename, 1, null);
        } catch (EcmaError e) {
            throw new ScriptException(e.getMessage(), e.sourceName(), e.lineNumber(), e.columnNumber());
        } catch (Exception e) {
            throw new ScriptException(e);
        } finally {
View Full Code Here

                ScriptableObject
                    .putProperty(scope, "response", wrappedResponse);
                ScriptableObject.putProperty(scope, "loader", wrappedLoader);
                ScriptableObject.putProperty(scope, "catalog", wrappedCatalog);

                cx.evaluateReader(scope, reader, script.getName(), 1, null);
            } catch (IOException e) {
                throw new RestletException(
                    "I/O error while loading script...",
                    Status.SERVER_ERROR_INTERNAL
                );
View Full Code Here

            scope.initStandardObjects(cx, true);
            scope.installRequire(cx, new java.util.ArrayList(), true);
            FileReader reader = new FileReader(myScript);
            /// Script script = cx.compileReader(reader, myScript.getName(), 1, null);
            /// script.exec(cx, scope);
            cx.evaluateReader(scope, reader, myScript.getName(), 1, null);
        } catch (IOException e) {
            throw new RuntimeException("I/O error while loading process script...");
        } finally {
            Context.exit();
        }
View Full Code Here

    @NeedsContext
    public JSLint fromReader(Reader reader, String name) throws IOException {
        try {
            Context cx = contextFactory.enterContext();
            ScriptableObject scope = cx.initStandardObjects();
            cx.evaluateReader(scope, reader, name, 1, null);
            Function lintFunc = (Function) scope.get("JSLINT", scope);
            return new JSLint(contextFactory, lintFunc);
        } finally {
            Context.exit();
        }
View Full Code Here

        + cx.getImplementationVersion());
    cx.setOptimizationLevel(-1);
    Global global = new Global();
    global.init(cx);
    scope = cx.initStandardObjects(global);
    cx.evaluateReader(scope, new InputStreamReader(sourceMap
        .openConnection().getInputStream()), sourceMap.getFile(), 1,
        null);
    cx.evaluateReader(scope, new InputStreamReader(env.openConnection()
        .getInputStream()), env.getFile(), 1, null);
    Scriptable lessEnv = (Scriptable) scope.get("lessenv", scope);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.