|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.caucho.es.Resin
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 void |
init(ESFactory factory)
|
static void |
main(java.lang.String[] argv)
|
static Script |
parse(java.lang.ClassLoader parentLoader,
Path[] scriptPath,
ReadStream is,
com.caucho.java.LineMap lineMap)
|
static Script |
parse(java.lang.ClassLoader parentLoader,
Path[] scriptPath,
ReadStream is,
com.caucho.java.LineMap lineMap,
long lastModified)
|
static Script |
parse(java.lang.ClassLoader parentLoader,
Path[] scriptPath,
ReadStream is,
java.lang.String name,
int line)
Parse a JavaScript file. |
static Script |
parse(Path path,
Path[] scriptPath)
Parse a JavaScript file and return a script object. |
static Script |
parse(ReadStream is,
Path[] scriptPath)
Parse a JavaScript file and return a script object. |
static Script |
parseFile(Path path,
Path[] scriptPath)
parseFile is a temporary testing API to distinguigh the parse routines for JavaScript |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Method Detail |
public static void init(ESFactory factory)
public static Script parse(java.lang.ClassLoader parentLoader, Path[] scriptPath, ReadStream is, java.lang.String name, int line) throws java.io.IOException, ESException
scriptPath
- List of paths for JavaScript importis
- The stream containing the JavaScriptname
- User name of the script for error messagesline
- Starting line of the script for error messagespublic static Script parse(java.lang.ClassLoader parentLoader, Path[] scriptPath, ReadStream is, com.caucho.java.LineMap lineMap) throws java.io.IOException, ESException
public static Script parse(java.lang.ClassLoader parentLoader, Path[] scriptPath, ReadStream is, com.caucho.java.LineMap lineMap, long lastModified) throws java.io.IOException, ESException
public static Script parse(ReadStream is, Path[] scriptPath) throws java.io.IOException, ESException
The scriptPath is just an array of Paths. The default is the directory of the script, followed by $RESIN_HOME/scripts.
Here's the default:
Path scriptPath[] = new Path[] {
is.getPath().getParent(),
CauchoSystem.getResinHome().lookup("scripts")
}
is
- The input stream to read the file.scriptPath
- A path of directories to search for JavaScript
imported files.public static Script parse(Path path, Path[] scriptPath) throws java.io.IOException, ESException
path
- The file path.scriptPath
- A path of directories to search for JavaScript
imported files.public static Script parseFile(Path path, Path[] scriptPath) throws java.io.IOException, ESException
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |