use of javax.script.ScriptEngineManager in project enhydrator by AdamBien.
the class ScriptingEnvironmentProviderTest method emptyRowHasMemory.
@Test
public void emptyRowHasMemory() {
Row row = new Row();
Memory expected = new Memory();
row.useMemory(expected);
Bindings bindings = ScriptingEnvironmentProvider.create(new ScriptEngineManager(), null, row);
Object actual = bindings.get("$MEMORY");
assertNotNull(actual);
assertThat(actual, is(expected));
}
use of javax.script.ScriptEngineManager in project enhydrator by AdamBien.
the class ScriptableSource method init.
public void init() throws IllegalStateException, IllegalArgumentException {
this.rows = new ArrayList<>();
this.charset = Charset.forName(charsetName);
ScriptEngineManager manager = new ScriptEngineManager();
this.nashorn = manager.getEngineByName("javascript");
}
use of javax.script.ScriptEngineManager in project enhydrator by AdamBien.
the class ScriptableSink method init.
@Override
public void init() {
requireNonNull(this.scriptFile, "Cannot initialize ScriptableSink without script.");
try {
this.scriptContent = load(this.scriptFile);
} catch (IOException ex) {
throw new IllegalStateException("Cannot load script from: " + this.scriptFile, ex);
}
ScriptEngineManager sem = new ScriptEngineManager();
this.engine = sem.getEngineByName("javascript");
try {
this.engine.eval(this.scriptContent);
} catch (ScriptException ex) {
throw new IllegalStateException("Parsing script failed. Problem in line: " + ex.getLineNumber() + " and column: " + ex.getColumnNumber(), ex);
}
this.invocable = (Invocable) engine;
this.sink = this.invocable.getInterface(Sink.class);
requireNonNull(this.sink, "Sink instantiation failed - script: " + this.scriptContent + " is incompatible");
this.sink.init();
}
use of javax.script.ScriptEngineManager in project java8-tutorial by winterbe.
the class Nashorn2 method main.
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(new FileReader("res/nashorn2.js"));
}
use of javax.script.ScriptEngineManager in project java8-tutorial by winterbe.
the class Nashorn3 method main.
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval("load('res/nashorn3.js')");
}
Aggregations