@Override protected Object jobRun() throws Throwable { String replName = getRequiredReplName(); Interpreter repl = getRepl(replName); logger().info("run paragraph {} using {} " + repl, getId(), replName); if (repl == null) { logger().error("Can not find interpreter name " + repl); throw new RuntimeException("Can not find interpreter for " + getRequiredReplName()); } String script = getScriptBody(); // inject form if (repl.getFormType() == FormType.NATIVE) { settings.clear(); } else if (repl.getFormType() == FormType.SIMPLE) { String scriptBody = getScriptBody(); Map<String, Input> inputs = Input.extractSimpleQueryParam(scriptBody); // inputs will be built // from script body settings.setForms(inputs); script = Input.getSimpleQuery(settings.getParams(), scriptBody); } logger().debug("RUN : " + script); try { InterpreterContext context = getInterpreterContext(); InterpreterContext.set(context); InterpreterResult ret = repl.interpret(script, context); if (Code.KEEP_PREVIOUS_RESULT == ret.code()) { return getReturn(); } String message = ""; context.out.flush(); InterpreterResult.Type outputType = context.out.getType(); byte[] interpreterOutput = context.out.toByteArray(); context.out.clear(); if (interpreterOutput != null && interpreterOutput.length > 0) { message = new String(interpreterOutput); } if (message.isEmpty()) { return ret; } else { String interpreterResultMessage = ret.message(); if (interpreterResultMessage != null && !interpreterResultMessage.isEmpty()) { message += interpreterResultMessage; return new InterpreterResult(ret.code(), ret.type(), message); } else { return new InterpreterResult(ret.code(), outputType, message); } } } finally { InterpreterContext.remove(); } }