@Test public void testAccessToJavaClassesTransformationExecution() throws ScriptException, IOException, NoSuchMethodException, URISyntaxException { thrown.expect(ScriptException.class); thrown.expectCause(CoreMatchers.isA(RuntimeException.class)); String javaClassAccessFunc = resourceFileToString("javaClassAccess.js"); transformationFunction = new TransformationFunction("3", javaClassAccessFunc); executionEngine.execute(jsonData, transformationFunction); }
@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);  }