use of com.walmartlabs.concord.runtime.v2.runner.ResourceResolver in project concord by walmartlabs.
the class ScriptCallCommand method execute.
@Override
protected void execute(Runtime runtime, State state, ThreadId threadId) {
state.peekFrame(threadId).pop();
Context ctx = runtime.getService(Context.class);
ExpressionEvaluator expressionEvaluator = runtime.getService(ExpressionEvaluator.class);
ScriptEvaluator scriptEvaluator = runtime.getService(ScriptEvaluator.class);
ResourceResolver resourceResolver = runtime.getService(ResourceResolver.class);
ScriptCall call = getStep();
ScriptCallOptions opts = Objects.requireNonNull(call.getOptions());
Map<String, Object> input = VMUtils.prepareInput(expressionEvaluator, ctx, opts.input(), opts.inputExpression());
String language = getLanguage(expressionEvaluator, scriptEvaluator, ctx, call);
Reader content = getContent(expressionEvaluator, resourceResolver, ctx, call);
ScriptResult scriptResult;
try {
scriptResult = scriptEvaluator.eval(ctx, language, content, input);
} finally {
try {
content.close();
} catch (IOException e) {
// we don't have to do anything about it, but we're going to log the error just in case
log.warn("Error while closing the script's reader: {}", e.getMessage() + ". This is most likely a bug.");
}
}
OutputUtils.process(runtime, ctx, scriptResult.items(), opts.out(), opts.outExpr());
}
Aggregations