@Test public void testConcatTransformationExecution() throws ScriptException, IOException, NoSuchMethodException, URISyntaxException { String concatFunc = resourceFileToString("concat.js"); transformationFunction = new TransformationFunction("1", concatFunc); JsonNode result = executionEngine.execute(jsonData, transformationFunction); Assert.assertEquals("13.929755188361455, 50.96458457915114", result.get("combinedCoords").asText()); }
@Override public ObjectNode execute(ObjectNode data, TransformationFunction transformationFunction) throws ScriptException, IOException, NoSuchMethodException { initNashornSandbox(); try { String script = wrapperScript + transformationFunction.getTransformFunction(); nashornSandbox.eval(script); Invocable sandboxedInvocable = nashornSandbox.getSandboxedInvocable(); String result = (String) sandboxedInvocable.invokeFunction(WRAPPER_FUNCTION, data.toString()); return (ObjectNode) JsonMapper.getInstance().readTree(result); } finally { ExecutorService executor = nashornSandbox.getExecutor(); executor.shutdown(); } }
NashornExecutionEngine extends AbstractExecutionEngine { @Override public ObjectNode execute(ObjectNode data, TransformationFunction transformationFunction) throws ScriptException, IOException, NoSuchMethodException { initNashornSandbox(); try { String script = wrapperScript + transformationFunction.getTransformFunction(); nashornSandbox.eval(script); Invocable sandboxedInvocable = nashornSandbox.getSandboxedInvocable(); String result = (String) sandboxedInvocable.invokeFunction(WRAPPER_FUNCTION, data.toString()); return (ObjectNode) JsonMapper.getInstance().readTree(result); } finally { ExecutorService executor = nashornSandbox.getExecutor(); executor.shutdown(); } } }
NashornExecutionEngine extends AbstractExecutionEngine { @Override public ObjectNode execute(ObjectNode data, TransformationFunction transformationFunction) throws ScriptException, IOException, NoSuchMethodException { initNashornSandbox(); try { String script = wrapperScript + transformationFunction.getTransformFunction(); nashornSandbox.eval(script); Invocable sandboxedInvocable = nashornSandbox.getSandboxedInvocable(); String result = (String) sandboxedInvocable.invokeFunction(WRAPPER_FUNCTION, data.toString()); return (ObjectNode) JsonMapper.getInstance().readTree(result); } finally { ExecutorService executor = nashornSandbox.getExecutor(); executor.shutdown(); } } NashornExecutionEngine(); }
NashornExecutionEngine extends AbstractExecutionEngine { @Override public ObjectNode execute(ObjectNode data, TransformationFunction transformationFunction) throws ScriptException, IOException, NoSuchMethodException { initNashornSandbox(); try { String script = wrapperScript + transformationFunction.getTransformFunction(); nashornSandbox.eval(script); Invocable sandboxedInvocable = nashornSandbox.getSandboxedInvocable(); String result = (String) sandboxedInvocable.invokeFunction(WRAPPER_FUNCTION, data.toString()); return (ObjectNode) JsonMapper.getInstance().readTree(result); } finally { ExecutorService executor = nashornSandbox.getExecutor(); executor.shutdown(); } } NashornExecutionEngine(); @Override ObjectNode execute(ObjectNode data, TransformationFunction transformationFunction); }
NashornExecutionEngine extends AbstractExecutionEngine { @Override public ObjectNode execute(ObjectNode data, TransformationFunction transformationFunction) throws ScriptException, IOException, NoSuchMethodException { initNashornSandbox(); try { String script = wrapperScript + transformationFunction.getTransformFunction(); nashornSandbox.eval(script); Invocable sandboxedInvocable = nashornSandbox.getSandboxedInvocable(); String result = (String) sandboxedInvocable.invokeFunction(WRAPPER_FUNCTION, data.toString()); return (ObjectNode) JsonMapper.getInstance().readTree(result); } finally { ExecutorService executor = nashornSandbox.getExecutor(); executor.shutdown(); } } NashornExecutionEngine(); @Override ObjectNode execute(ObjectNode data, TransformationFunction transformationFunction);  }