classes are com.caucho.es.parser.Parser and com.caucho.es.Script.
Parser is a factory for generating scripts and Script is a
and then execute it.
Parser is a factory for parsing Scripts and Script represents a
Most application will set the script path and the work directory.
files. MergePath is handy since it lets you build a list of
directories to search. You can also add the classpath to the list of
directories to search by calling addClassPath. The default search
path is the current directory of the process (e.g. server-home) and
includes the classpath. So a simple application can just put
The work directory specifies where the generated *.java and
*.class will go. The parser will try to load a precompiled script
before parsing the script. If any of the source files have changed,
the parser will recompile the script.
Compiling a Script
com.caucho.es.parser.Parser parser = Resin.getParser();
MergePath scriptPath = new MergePath();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Path workPath = Vfs.lookup("/tmp/caucho/work");
Script script = parser.parse("test.js");
Once the script is compiled, the application can execute it. The
including the global objects, have their own copy for each execution.
Custom global objects can be configured by adding them to a
HashMap in the script call.
Executing a Script
Bean myBean = ...;
HashMap properties = new HashMap();
Path pwd = Vfs.lookup(".");
|Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.|
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.