Package org.mozilla.javascript

Examples of org.mozilla.javascript.Scriptable


    public Object evaluate(String script, String filename, Map<String, Object> args)
            throws ScriptException, Throwable {
        RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
        Context cx = factory.enterContext();
        ScriptableObject scriptable = new ImporterTopLevel(cx);
        Scriptable scope = cx.initStandardObjects(scriptable);

        for (Map.Entry<String, Object> entry : args.entrySet()) {
            ScriptableObject.putProperty(scope, entry.getKey(),
                    Context.javaToJS(entry.getValue(), scope));
        }
View Full Code Here


    @Override
    public Object eval(String script, ScriptContext context)
            throws ScriptException {

        Scriptable scope = setupScope(cx, context);

        String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null
                ? "<unknown>" : filename;

        try {
View Full Code Here

    @Override
    public Object eval(Reader reader, ScriptContext context)
            throws ScriptException {

        Scriptable scope = setupScope(cx, context);

        String filename = (filename = (String) get(ScriptEngine.FILENAME)) == null
                ? "<unknown>" : filename;

        try {
View Full Code Here

        }
    }

    private Scriptable setupScope(Context cx, ScriptContext context) {
        ScriptableObject scriptable = new ImporterTopLevel(cx);
        Scriptable scope = cx.initStandardObjects(scriptable);
        //ScriptableObject.putProperty(scope, "argv", Context.javaToJS(args, scope));
        return scope;
    }
View Full Code Here

     */
    public void bindObject(String name, Object object) {
        Context ctx = Context.enter();
        ctx.setWrapHandler(wrapHandler);
        try {
            Scriptable jsObject =  Context.toObject(object, globalObject);
            globalObject.put(name, globalObject, jsObject);
        } finally {
            Context.exit();
        }

View Full Code Here

        throw new Error(e.getMessage());
      }

      // Define some global variables in JavaScript
      Object args[] = {};
      Scriptable log = context.newObject(scope, "Log", args);
      ((JSLog)log).setLogger(getLogger());
      scope.put("log", scope, log);

    } catch (Exception e) {
      context.exit();
View Full Code Here

    throws Exception
  {
    Context context = Context.enter();
    context.setOptimizationLevel(OPTIMIZATION_LEVEL);
    context.setCompileFunctionsWithDynamicScope(true);
    Scriptable thrScope = context.newObject(scope);

    thrScope.setPrototype(scope);
    // We want 'thrScope' to be a new top-level scope, so set its
    // parent scope to null. This means that any variables created
    // by assignments will be properties of "thrScope".
    thrScope.setParentScope(null);

    // Put in the thread scope the Cocoon object, which gives access
    // to the interpreter object, and some Cocoon objects. See
    // JSCocoon for more details.
    Object args[] = {};
    Scriptable cocoon = context.newObject(scope, "Cocoon", args);
    ((JSCocoon)cocoon).setInterpreter(this);
    ((JSCocoon)cocoon).setContext(manager, environment, ctx);
    ((JSCocoon)cocoon).setContinuationsManager(continuationsMgr);
    ((JSCocoon)cocoon).setScope(thrScope);
    thrScope.put("cocoon", thrScope, cocoon);
View Full Code Here

  }

  public Source readScript(Environment environment, String sourceName)
    throws Exception
  {
    Scriptable thrScope = null;
    Source source = null;

    System.out.println("Reading file " + sourceName);

    try {
View Full Code Here

  public void callFunction(String funName, List params,
                           Environment environment, InvokeContext ctx)
    throws Exception
  {
    Scriptable thrScope = null;

    checkForModifiedScripts(environment);

    try {
      thrScope = enterContext(environment, ctx);
View Full Code Here

    // JSCocoon object associated in the dynamic scope of the saved
    // continuation with the environment and context objects.
    JSWebContinuation jswk = (JSWebContinuation)wk.getUserObject();
    JSCocoon cocoon = jswk.getJSCocoon();
    cocoon.setContext(manager, environment, ctx);
    Scriptable kScope = cocoon.getScope();

    // We can now resume the processing from the state saved by the
    // continuation object. Setup the JavaScript Context object.
    Object handleContFunction = scope.get("handleContinuation", kScope);
    if (handleContFunction == Scriptable.NOT_FOUND)
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Scriptable

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.