use of javax.script.ScriptEngineManager in project bytecode-viewer by Konloch.
the class GroovyPluginLaunchStrategy method run.
@Override
public Plugin run(File file) throws Throwable {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("groovy");
if (engine == null)
throw new Exception("Cannot find Groovy script engine! Please contact Konloch.");
Reader reader = new FileReader(file);
engine.eval(reader);
return (Plugin) engine.eval("new " + file.getName().replace(".gy", "").replace(".groovy", "") + "();");
}
use of javax.script.ScriptEngineManager in project bytecode-viewer by Konloch.
the class PythonPluginLaunchStrategy method run.
@Override
public Plugin run(File file) throws Throwable {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("python");
if (engine == null)
throw new Exception("Cannot find Jython script engine! Please contact Konloch.");
Reader reader = new FileReader(file);
engine.eval(reader);
return (Plugin) engine.eval(file.getName().replace(".py", "").replace(".python", "") + "()");
}
use of javax.script.ScriptEngineManager in project bytecode-viewer by Konloch.
the class RubyPluginLaunchStrategy method run.
@Override
public Plugin run(File file) throws Throwable {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jruby");
if (engine == null)
throw new Exception("Cannot find jRuby script engine! Please contact Konloch.");
Reader reader = new FileReader(file);
engine.eval(reader);
return (Plugin) engine.eval(file.getName().replace(".rb", "").replace(".ruby", "") + ".new");
}
use of javax.script.ScriptEngineManager in project incubator-atlas by apache.
the class Titan0Graph method getGremlinScriptEngine.
@Override
public ScriptEngine getGremlinScriptEngine() throws AtlasBaseException {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("gremlin-groovy");
if (engine == null) {
throw new AtlasBaseException(AtlasErrorCode.FAILED_TO_OBTAIN_GREMLIN_SCRIPT_ENGINE, "gremlin-groovy");
}
//Do not cache script compilations due to memory implications
engine.getContext().setAttribute("#jsr223.groovy.engine.keep.globals", "phantom", ScriptContext.ENGINE_SCOPE);
return engine;
}
use of javax.script.ScriptEngineManager in project lucene-solr by apache.
the class StatelessScriptUpdateProcessorFactoryTest method testForceEngine.
public void testForceEngine() throws Exception {
Assume.assumeNotNull((new ScriptEngineManager()).getEngineByName("javascript"));
final String chain = "force-script-engine";
SolrInputDocument d = processAdd(chain, doc(f("id", "5"), f("name", " foo "), f("subject", "bar")));
assertEquals(chain + " didn't add Double field", 42.3d, d.getFieldValue("script_added_d"));
assertEquals(chain + " didn't add integer field", new Integer(42), d.getFieldValue("script_added_i"));
}
Aggregations