Package org.mozilla.javascript

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


        myScript = algorithm;
        Context cx = Context.enter();
        try {
            scope = cx.initStandardObjects();
            FileReader reader = new FileReader(myScript);
            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


                ScriptableObject.putProperty(scope, "request", wrappedRequest);
                ScriptableObject
                    .putProperty(scope, "response", wrappedResponse);
                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

            if (filename == null) {
                filename = (String) get(RhinoScriptEngine.FILENAME);
            }
           
            filename = filename == null ? "<Unknown source>" : filename;
            ret = cx.evaluateReader(scope, preProcessScriptSource(reader), filename , 1null);
        } catch (JavaScriptException jse) {
            if (DEBUG) jse.printStackTrace();
            int line = (line = jse.lineNumber()) == 0 ? -1 : line;
            Object value = jse.getValue();
            String str = (value != null && value.getClass().getName().equals("org.mozilla.javascript.NativeError") ?
View Full Code Here

        throws InterpreterException, IOException {

        Object rv = null;
        final Context ctx = enterContext();
        try {
            rv = ctx.evaluateReader(globalObject,
                                    scriptreader,
                                    description,
                                    1, rhinoClassLoader);
        } catch (JavaScriptException e) {
            // exception from JavaScript (possibly wrapping a Java Ex)
View Full Code Here

    throw new CannotExecuteException ("No script.");
      }
      Context cx = Context.enter();
      Scriptable scope = prepareScope (cx, activity, formPars, map);
      Reader sr = new StringReader (script);
      cx.evaluateReader (scope, sr, "<script>", 1, null);
      result.set(convertResult(cx, scope, formPars));
  } catch (AbandonedException e) {
      // thrown when the activity was deliberatly abandoned.
      result.set (new ExceptionResult (e.getMessage ()));
  } catch (RemoteException e) {
View Full Code Here

              ("servletContext", servletContext,
               ScriptableObject.PERMANENT | ScriptableObject.READONLY);
            InputStream is
                = servletContext.getResourceAsStream("initScript.js");           
            Reader sr = new InputStreamReader (is, "ISO-8859-1");
            cx.evaluateReader (scope, sr, "<script>", 1, null);
        } catch (IOException e) {
            throw new ServletException (e);
        } finally {
            Context.exit();
        }
View Full Code Here

    try {
      if(args.length > 1){
        for(int i=1; i<args.length; i++){
          File includeFile = new File(args[i]);
          cx.evaluateReader(scope, new FileReader(includeFile), includeFile.getName(), 1, null);
        }
      }
     
      cx.evaluateReader(scope, new FileReader(file), file.getName(), 1, null);
     
View Full Code Here

          File includeFile = new File(args[i]);
          cx.evaluateReader(scope, new FileReader(includeFile), includeFile.getName(), 1, null);
        }
      }
     
      cx.evaluateReader(scope, new FileReader(file), file.getName(), 1, null);
     
    } finally {
      Context.exit();
    }
View Full Code Here

        "navigator", Context.javaToJS(new Navigator(), globalScope), ScriptableObject.DONTENUM);

    Reader soyutils = new InputStreamReader(new FileInputStream(soyUtilsPath), Charsets.UTF_8);
    try {
      String basename = soyUtilsPath.substring(soyUtilsPath.lastIndexOf('/') + 1);
      context.evaluateReader(globalScope, soyutils, basename, 1, null);
    } finally {
      soyutils.close();
    }

    globalScope.defineProperty(
View Full Code Here

      try {
        String soyutilsPath = getSoyUtilsPath();
        Reader soyutils = new InputStreamReader(new FileInputStream(soyutilsPath), Charsets.UTF_8);
        try {
          String basename = soyutilsPath.substring(soyutilsPath.lastIndexOf('/') + 1);
          context.evaluateReader(globalScope, soyutils, basename, 1, null);
        } finally {
          soyutils.close();
        }
      } catch (IOException ex) {
        throw new AssertionError(ex);
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.