Creating Scripting Engine in GumTree_96501863 - Gumtree/gumtree GitHub Wiki
Created by Tony Lam, last modified on Aug 05, 2008
GumTree uses JSR 223 (available in Java 6) as the facade API to provide scripting support. Since GumTree runs on top of the OSGi runtime, special treatment is required to ensure all scripting engines are visible during runtime (via extension point and global classloader visibility).
To use the scripting support, you need to create an instance of the script engine. The following code creates an engine in its current thread:
Some script engines place a restriction on thread. For example, Jepp only allows caller thread to be the same as its creator thread (in order to avoid multithreading issue when calling JNI). GumTree supports creation and execution of the script engine in new thread by using the script executor:
ScriptEngine engine = ScriptingCore.getScriptingManager().createEngine() engine.eval("print 'hello world'");
IScriptExecutor executor = new ScriptExecutor(); executor.runScript("print 'hello world'");
Document generated by Confluence on Apr 01, 2015 00:11