|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
ESCallable |
Class Summary | |
Call | Implementation class representing a call context. |
ConstIntMap | |
ESArrayWrapper | JavaScript object |
ESBase | Implementation class for the base of the JavaScript object hierarchy. |
ESBeanWrapper | Implementation class serving as the base for wrapped Java objects. |
ESBoolean | Implementation class for JavaScript booleans. |
ESClass | |
ESClosure | Implementation class representing a JavaScript function. |
ESFactory | Factory for creating the base objects, allowing sophisticated script users to override the implementations. |
ESGlobal | Implementation class representing the global object. |
ESId | |
ESNull | |
ESNumber | Implementation class for JavaScript numbers. |
ESObject | Implementation class for a JavaScript Object. |
ESRegexp | |
ESString | Implementation class for JavaScript strings. |
ESUndefined | |
Global | Implementation class for the global prototype |
Resin | Resin is the primary public entry to the JavaScript compiler. |
Script | The Script object represents a compiled JavaScript. |
ScriptClosure | ScriptClosure lets Java programs call JavaScript functions. |
Exception Summary | |
ESException | JavaScript exception, filtered to get the line numbers right. |
ESNullException | JavaScript exception |
ESParseException | JavaScript exception |
ESUndefinedException | JavaScript exception |
ESWrapperException | JavaScript exception |
The JavaScript compiler package. The Resin class is the primary public entry.
The public classes are Resin, Script, and ScriptClosure. Resin is the main entry to the compiler. Script contains a compiled script. ScriptClosure lets programs execute the global script and then call back into the JavaScript. The other classes are public only because JavaScript gets compiled to Java. The generated Java classes need to access the JavaScript libraries.
The script must first be compiled to a Script object, then executed. The following example gives the bare-bones script invocation.
Script script = Resin.parse(Pwd.lookup("foo.js"), null);
script.execute(null, null);
You can make Java objects available to the Script by adding them to a HashMap. For example, the File object. The running script will see these objects as properties of the Global object. If you set the 'out' object, the script can use 'writeln("foo")' to write to 'out'.
HashMap map = new HashMap();
map.put("File", Pwd.lookup());
map.put("out", System.out);
map.put("myObject", myObject);
script.execute(map, null);
You can also make any Java object be the global prototype. Essentially, the effect is similar to the HashMap technique, but it's a little simpler.
The Script object is threadsafe. It's safe to execute the same script in multiple threads.
The ScriptClosure object, of course, is not threadsafe.
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |