Search in sources :

Example 1 with Callable

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;
}
Also used : CompilationContext(sirius.pasta.noodle.compiler.CompilationContext) NoodleCompiler(sirius.pasta.noodle.compiler.NoodleCompiler) Callable(sirius.pasta.noodle.Callable)

Example 2 with 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()));
}
Also used : HandledException(sirius.kernel.health.HandledException) SimpleEnvironment(sirius.pasta.noodle.SimpleEnvironment) Watch(sirius.kernel.commons.Watch) CompileException(sirius.pasta.noodle.compiler.CompileException) Callable(sirius.pasta.noodle.Callable) HandledException(sirius.kernel.health.HandledException) ScriptingException(sirius.pasta.noodle.ScriptingException) CompileException(sirius.pasta.noodle.compiler.CompileException) ScriptingException(sirius.pasta.noodle.ScriptingException)

Aggregations

Callable (sirius.pasta.noodle.Callable)2 Watch (sirius.kernel.commons.Watch)1 HandledException (sirius.kernel.health.HandledException)1 ScriptingException (sirius.pasta.noodle.ScriptingException)1 SimpleEnvironment (sirius.pasta.noodle.SimpleEnvironment)1 CompilationContext (sirius.pasta.noodle.compiler.CompilationContext)1 CompileException (sirius.pasta.noodle.compiler.CompileException)1 NoodleCompiler (sirius.pasta.noodle.compiler.NoodleCompiler)1