NetRexx JSR 223 Script Engine
This
document contains information about the NetRexx Script Engine created
to allow NetRexx to run as a Java JSR 223 scripting language.
2009-11-16 Usage notes for current experimental test version (subject to change as development proceeds):
- The
jar file containing the engine is NetRexxJSR223.jar and it must be
installed along with the NetRexxC.jar language library in the same
directory.
- The actual name of the script engine is
jsr223.netrexx.NetRexxScriptEngine but only the last part of the name
is needed for access from scripts.
- All engine scope bindings
are passed to the script as variables - note that binding names
containing periods have the periods changed to underscores.
- Arguments are passed both as the normal "arg" string and as the array binding
"javax.script.argv" ie script variable "javax_script_argv". - To
return an object to the calling platform the script must place it in a
binding before exiting like this:
NetRexxScriptEngine.instance.put("returnobject",~someobject~)
- The current version of the engine
has no optimization and only support for bare minimum features (No
compilable, invokeable, preparse or caching or user profiles or
console, etc.).
- Programs
must be scripts only at this time - you cannot define the primary class
or use imports yet like a full program might do.
- The jar file
contains a simple "print hello" verification program which can be
executed like this: java -jar NetRexxJSR223.jar
- More complex testing can be done using the jrunscript program from the latest JDK as follows:
- Prompt
mode testing (one line ad hoc programs - use CTRL Z, ENTER to exit on
Windows anyway): jrunscript -cp NetRexxJSR223.jar -l NetRexx
- Pass a script file to the engine like this: jrunscript -cp NetRexxJSR223.jar -l NetRexx -f myprogram.nrx
- Programs
currently are copied to a file in
System.getProperty('user.home')/scripts/prefixed with code added to the
front to import bindings variables.
Questions that need answers:
- Does it work on *nix systems also?
- Can it run as a JSR223 engine under the jEdit ScriptEnginePlugin?
- Can it run as a BSF 3.0 script engine?
- Can this run as an extension (ext directory)?
- What platforms can actually use a JSR223 engine? Eclipse? OpenOffice? ...?
- It seems like embedded web services might be a target for this application - can anyone test there? Glassfish?
- Who can help test this and provide suggestions?
- Can Rene act as a backup repository admin or provide a general NetRexx repository?
Features that need to be added before a production release can happen, etc:
- NetRexxA parse and reflection call
- Cache parsed scripts
- Preparse any scripts in user.home/scripts directories
- Add support for user profile variables and options panel to set them
- Add an optional script console to view detailed script output and parse output
- Reflecting errors to the original code would be nice!
- Add compilable and invokeable support
- Add hashcode file signatures with length in case originating file system is not available to identify cached scripts
- build.xml that works for *nix and Windows both!
- Sample scripts to demo/test all features.
- Test generation of source code distributions.
- Obtain an online SVN repository location.
- *** Add support for redirected print streams and input streams ***
- dynamic classpath support