public final class

RhinoTopLevel

extends ImporterTopLevel
java.lang.Object
   ↳ sun.org.mozilla.javascript.internal.ScriptableObject
     ↳ sun.org.mozilla.javascript.internal.IdScriptableObject
       ↳ sun.org.mozilla.javascript.internal.ImporterTopLevel
         ↳ com.sun.script.javascript.RhinoTopLevel

Class Overview

This class serves as top level scope for Rhino. This class adds 3 top level functions (bindings, scope, sync) and two constructors (JSAdapter, JavaAdapter).

Summary

[Expand]
Inherited Constants
From class sun.org.mozilla.javascript.internal.ScriptableObject
[Expand]
Inherited Fields
From interface sun.org.mozilla.javascript.internal.Scriptable
Public Methods
static Object bindings(Context cx, Scriptable thisObj, Object[] args, Function funObj)
The bindings function takes a JavaScript scope object of type ExternalScriptable and returns the underlying Bindings instance.
static Object scope(Context cx, Scriptable thisObj, Object[] args, Function funObj)
The scope function creates a new JavaScript scope object with given Bindings object as backing store.
static Object sync(Context cx, Scriptable thisObj, Object[] args, Function funObj)
The sync function creates a synchronized function (in the sense of a Java synchronized method) from an existing function.
[Expand]
Inherited Methods
From class sun.org.mozilla.javascript.internal.ImporterTopLevel
From class sun.org.mozilla.javascript.internal.IdScriptableObject
From class sun.org.mozilla.javascript.internal.ScriptableObject
From class java.lang.Object
From interface sun.org.mozilla.javascript.internal.IdFunctionCall
From interface sun.org.mozilla.javascript.internal.Scriptable
From interface sun.org.mozilla.javascript.internal.debug.DebuggableObject

Public Methods

public static Object bindings (Context cx, Scriptable thisObj, Object[] args, Function funObj)

The bindings function takes a JavaScript scope object of type ExternalScriptable and returns the underlying Bindings instance. var page = scope(pageBindings); with (page) { // code that uses page scope } var b = bindings(page); // operate on bindings here.

public static Object scope (Context cx, Scriptable thisObj, Object[] args, Function funObj)

The scope function creates a new JavaScript scope object with given Bindings object as backing store. This can be used to create a script scope based on arbitrary Bindings instance. For example, in webapp scenario, a 'page' level Bindings instance may be wrapped as a scope and code can be run in JavaScripe 'with' statement: var page = scope(pageBindings); with (page) { // code that uses page scope }

public static Object sync (Context cx, Scriptable thisObj, Object[] args, Function funObj)

The sync function creates a synchronized function (in the sense of a Java synchronized method) from an existing function. The new function synchronizes on the this object of its invocation. js> var o = { f : sync(function(x) { print("entry"); Packages.java.lang.Thread.sleep(x*1000); print("exit"); })}; js> thread(function() {o.f(5);}); entry js> thread(function() {o.f(5);}); js> exit entry exit