use of sirius.pasta.noodle.Callable in project sirius-biz by scireum.
the class Scripting method compileScript.
private Callable compileScript(JSONObject event) throws CompileException {
CompilationContext compilationContext = new CompilationContext(SourceCodeInfo.forInlineCode(event.getString(TASK_SCRIPT)));
NoodleCompiler compiler = new NoodleCompiler(compilationContext);
Callable callable = compiler.compileScript();
compilationContext.processCollectedErrors();
return callable;
}
use of sirius.pasta.noodle.Callable in project sirius-biz by scireum.
the class Scripting method handleExecTask.
private void handleExecTask(JSONObject event) {
String nodeName = event.getString(TASK_NODE);
String jobNumber = event.getString(TASK_JOB);
if (!ALL_NODES.equals(nodeName) && !Strings.areEqual(CallContext.getNodeName(), nodeName)) {
return;
}
Watch watch = Watch.start();
logInTranscript(jobNumber, Strings.apply("Starting execution on %s (Thread Id: %s / Thread Name: %s)", CallContext.getNodeName(), Thread.currentThread().getId(), Thread.currentThread().getName()));
try {
Callable callable = compileScript(event);
TaskContext.get().setAdapter(new JobTaskContextAdapter(this, jobNumber));
callable.call(new SimpleEnvironment());
} catch (CompileException | ScriptingException | HandledException e) {
logInTranscript(jobNumber, e.getMessage());
} catch (Exception e) {
logInTranscript(jobNumber, Exceptions.handle(Pasta.LOG, e).getMessage());
}
logInTranscript(jobNumber, Strings.apply("Execution completed (%s)", watch.duration()));
}
Aggregations