use of javax.script.ScriptEngineManager in project adempiere by adempiere.
the class MRule method getScriptEngine.
// toString
/**
* Script Engine for this rule
* @return ScriptEngine
*/
public ScriptEngine getScriptEngine() {
factory = new ScriptEngineManager();
String engineName = getEngineName();
if (engineName != null)
engine = factory.getEngineByName(engineName);
return engine;
}
use of javax.script.ScriptEngineManager in project lucene-solr by apache.
the class ScriptTransformer method initEngine.
private void initEngine(Context context) {
String scriptText = context.getScript();
String scriptLang = context.getScriptLanguage();
if (scriptText == null) {
throw new DataImportHandlerException(SEVERE, "<script> tag is not present under <dataConfig>");
}
ScriptEngineManager scriptEngineMgr = new ScriptEngineManager();
ScriptEngine scriptEngine = scriptEngineMgr.getEngineByName(scriptLang);
if (scriptEngine == null) {
throw new DataImportHandlerException(SEVERE, "Cannot load Script Engine for language: " + scriptLang);
}
if (scriptEngine instanceof Invocable) {
engine = (Invocable) scriptEngine;
} else {
throw new DataImportHandlerException(SEVERE, "The installed ScriptEngine for: " + scriptLang + " does not implement Invocable. Class is " + scriptEngine.getClass().getName());
}
try {
scriptEngine.eval(scriptText);
} catch (ScriptException e) {
wrapAndThrow(SEVERE, e, "'eval' failed with language: " + scriptLang + " and script: \n" + scriptText);
}
}
use of javax.script.ScriptEngineManager in project lucene-solr by apache.
the class ScriptEngineTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
manager = new ScriptEngineManager();
}
use of javax.script.ScriptEngineManager in project lucene-solr by apache.
the class TestBadConfig method testMissingScriptFile.
public void testMissingScriptFile() throws Exception {
// sanity check
Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
assertConfigs("bad-solrconfig-missing-scriptfile.xml", "schema.xml", "a-file-name-that-does-not-exist.js");
}
use of javax.script.ScriptEngineManager in project lucene-solr by apache.
the class TestBadConfig method testInvalidScriptFile.
public void testInvalidScriptFile() throws Exception {
// sanity check
Assume.assumeNotNull((new ScriptEngineManager()).getEngineByName("javascript"));
assertConfigs("bad-solrconfig-invalid-scriptfile.xml", "schema.xml", "currency.xml");
}
Aggregations