com.caucho.es
Class Resin

java.lang.Object
  |
  +--com.caucho.es.Resin

public class Resin
extends java.lang.Object

Resin is the primary public entry to the JavaScript compiler.

The script must first be compiled, then executed.

JavaScript import uses a script path to located the imported script. The scriptPath is just an array of Paths. If the scriptPath is null, Resin will default to the script's directory, followed by $RESIN_HOME/scripts.

Here's the default, where 'is' is the input stream:


 Path scriptPath[] = new Path[] {
   is.getPath().getParent(),
   CauchoSystem.getResinHome().lookup("scripts")
 }
 

As described in the Script object, programs set global variables with a hash map. So a simple call might look like:


 Script script = Resin.parse(Pwd.lookup("foo.js"), scriptPath);

 HashMap props = new HashMap();
 props.put("out", System.out);

 script.execute(props, null);
 

Executing the Script object is threadsafe. The ScriptClosure object, of course, is not threadsafe.


Method Summary
static com.caucho.es.parser.Parser getParser()
           
static void init(ESFactory factory)
           
static void main(java.lang.String[] argv)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init(ESFactory factory)

getParser

public static com.caucho.es.parser.Parser getParser()
                                             throws java.io.IOException,
                                                    ESException

main

public static void main(java.lang.String[] argv)