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.
|