René and anyone else who is interested --
I have uploaded a new NetRexx JSR223 script engine for testing. Source is in the contrib repository. The source zip file and the NetRexxJSR223.jar file can be downloaded from the NetRexx Plus project on Kenai: http://kenai.com/projects/netrexx-plus/downloads This engine uses the NetRexxA API for interpreting programs from strings so there is no file IO or Java compiler overhead to process the scripts. Otherwise it is not particularly optimized although it is more efficient with the experimental after3.01 NetRexx as the interpreter does not need to be reloaded for every script with that version. Highlights from the rather limited documentation: 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. 2012-11-28 Usage notes for current version: * The jar file containing the engine is NetRexxJSR223.jar and it must be installed along with the NetRexxC.jar library (in the same directory if you want to try java -jar NetRexxJSR223). * The actual name of the script engine is org.netrexx.jsr223.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 to be legal variable names. * 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 special binding before exiting like this: NetRexxScriptEngine.putObject("returnobject",~someobject~) * Scripts are executed via the NetRexxA API for interpreting a program from a string so they are not written to files. Other than that - * The current version of the engine has no other optimization and only support for bare minimum JSR223 features (No compilable, invokeable, preparse or caching or user profiles or console, etc.). * When running as an Ant Script task, properties whose names contain periods are not passed to the bindings and must be accessed via project.getProperty('some.name') * The genius who designed Ant local properties did not allow bulk access, so they are not passed in the bindings which means the above line is true for them also unless ==> * Workaround - Simply define a local Ant property as a global first and the scriptengine will overlay the global value with the local value in the bindings map * 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 NetRexxJSR233.jar -l NetRexx -f myprogram.nrx * When running as an Ant Script task, properties can be set via project.setProperty('some.name','some value') * There are no standards for jsr223 interactions that are helpful for NetRexx so I created my own: * Script parms can be passed in an "arg" binding. Parse flags can be passed with a "netrexxflags" binding or in Ant with the usual "ant.netrexx.verbose", etc properties. * Ant scripts can use the nested classpath facility - It is automatically added to the classpath that NetRexx scans. Likewise any path segments from a thread context URLclassloader. * The engine will run programs (ie that have a main class) as well as scripts but bindings cannot then be auto added to the program namespace so- * Programs have to load bindings like this: NetRexxScriptEngine.getObject("objectname") -------------------------------------------------------------------------------------------------------------------------------------------- In theory, a JSR223 script engine allows a script language to run in any environment with JSR223 support. In practice I found that the JSR223 specification is so poorly defined that each such environment implements it differently. This version is customized to work in the Ant build environment where I needed it and I don't know if it will work anywhere else although I tested it with the command line options listed above. For example, NetRexx needs a classpath to run so the engine steals one from the Ant thread context classloader. Other environments may require further customization to work correctly. Testers will be much appreciated! I won't even talk about the difficulty in obtaining something as simple as a program name which is required for NetRexx but is not required for JSR223 implementations to provide! Future considerations: I started this project back in 2009 as you may recall, but put it on hold pending open source NetRexx and a suitable environment for testing it. Since that was long before NetRexx open source, the license in it is GPL2. I can change that to ICU if needed. In theory, this script engine should be added to the NetRexxC.jar file so that NetRexx support can be added to any JSR223 environment with a single jar file. But I recommend that we hold on that until we have more experience with different JSR223 host environments and know what customizations might be needed there. Have fun, -- Kermit _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Kermit,
thank you, excellent work. Q: "What is the difference between Maven and Ant?" A: "The maker of Ant has apologized." (http://duncandavidson.tumblr.com/post/470882637/q-whats-the-difference-between-ant-and-maven-a) James Duncan Davidson has written Ant and has since been a photographer. I admire his work on Tomcat though. I'll try to use it in other environments than Ant and will report back. best regards, René. On 2012-11-29 04:13, Kermit Kiser wrote: > René and anyone else who is interested -- > > I have uploaded a new NetRexx JSR223 script engine for testing. > Source is in the contrib repository. The source zip file and the > NetRexxJSR223.jar file can be downloaded from the NetRexx Plus project > on Kenai: > > http://kenai.com/projects/netrexx-plus/downloads > > This engine uses the NetRexxA API for interpreting programs from > strings so there is no file IO or Java compiler overhead to process > the scripts. Otherwise it is not particularly optimized although it is > more efficient with the experimental after3.01 NetRexx as the > interpreter does not need to be reloaded for every script with that > version. > > Highlights from the rather limited documentation: > > 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. > 2012-11-28 Usage notes for current version: > > * The jar file containing the engine is NetRexxJSR223.jar and it > must be installed along with the NetRexxC.jar library (in the same > directory if you want to try java -jar NetRexxJSR223). > * The actual name of the script engine is > org.netrexx.jsr223.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 to be legal variable names. > * 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 special binding before exiting like this: > NetRexxScriptEngine.putObject("returnobject",~someobject~) > * Scripts are executed via the NetRexxA API for interpreting a > program from a string so they are not written to files. Other than > that - > * The current version of the engine has no other optimization and > only support for bare minimum JSR223 features (No compilable, > invokeable, preparse or caching or user profiles or console, etc.). > * When running as an Ant Script task, properties whose names > contain periods are not passed to the bindings and must be accessed > via project.getProperty('some.name') > * The genius who designed Ant local properties did not allow bulk > access, so they are not passed in the bindings which means the above > line is true for them also unless ==> > * Workaround - Simply define a local Ant property as a global > first and the scriptengine will overlay the global value with the > local value in the bindings map > * 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 > NetRexxJSR233.jar -l NetRexx -f myprogram.nrx > * When running as an Ant Script task, properties can be set via > project.setProperty('some.name','some value') > * There are no standards for jsr223 interactions that are helpful > for NetRexx so I created my own: > * Script parms can be passed in an "arg" binding. Parse flags can > be passed with a "netrexxflags" binding or in Ant with the usual > "ant.netrexx.verbose", etc properties. > * Ant scripts can use the nested classpath facility - It is > automatically added to the classpath that NetRexx scans. Likewise any > path segments from a thread context URLclassloader. > * The engine will run programs (ie that have a main class) as > well as scripts but bindings cannot then be auto added to the program > namespace so- > * Programs have to load bindings like this: > NetRexxScriptEngine.getObject("objectname") > -------------------------------------------------------------------------------------------------------------------------------------------- > In theory, a JSR223 script engine allows a script language to run in > any environment with JSR223 support. In practice I found that the > JSR223 specification is so poorly defined that each such environment > implements it differently. This version is customized to work in the > Ant build environment where I needed it and I don't know if it will > work anywhere else although I tested it with the command line options > listed above. For example, NetRexx needs a classpath to run so the > engine steals one from the Ant thread context classloader. Other > environments may require further customization to work correctly. > Testers will be much appreciated! I won't even talk about the > difficulty in obtaining something as simple as a program name which is > required for NetRexx but is not required for JSR223 implementations to > provide! > > Future considerations: I started this project back in 2009 as you may > recall, but put it on hold pending open source NetRexx and a suitable > environment for testing it. Since that was long before NetRexx open > source, the license in it is GPL2. I can change that to ICU if needed. > In theory, this script engine should be added to the NetRexxC.jar file > so that NetRexx support can be added to any JSR223 environment with a > single jar file. But I recommend that we hold on that until we have > more experience with different JSR223 host environments and know what > customizations might be needed there. > > Have fun, > -- Kermit > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |