Search in sources :

Example 1 with MethodNotFoundException

use of com.walmartlabs.concord.runtime.v2.runner.el.MethodNotFoundException in project concord by walmartlabs.

the class TaskMethodResolver method invoke.

@Override
public Object invoke(ELContext elContext, Object base, Object method, Class<?>[] paramTypes, Object[] params) {
    Step step = context.execution().currentStep();
    if (!(step instanceof Expression) || !(base instanceof Task) || !(method instanceof String)) {
        return null;
    }
    String taskName = getName(base);
    if (taskName == null) {
        return null;
    }
    CallContext callContext = TaskCallInterceptor.CallContext.builder().taskName(taskName).correlationId(context.execution().correlationId()).currentStep(step).processDefinition(context.execution().processDefinition()).build();
    TaskCallInterceptor interceptor = context.execution().runtime().getService(TaskCallInterceptor.class);
    try {
        return interceptor.invoke(callContext, Method.of(base, (String) method, Arrays.asList(params)), () -> super.invoke(elContext, base, method, paramTypes, params));
    } catch (javax.el.MethodNotFoundException e) {
        throw new MethodNotFoundException(base, method, paramTypes);
    } catch (javax.el.ELException e) {
        if (e.getCause() instanceof RuntimeException) {
            throw (RuntimeException) e.getCause();
        }
        throw e;
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Task(com.walmartlabs.concord.runtime.v2.sdk.Task) Expression(com.walmartlabs.concord.runtime.v2.model.Expression) Step(com.walmartlabs.concord.runtime.v2.model.Step) CallContext(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor.CallContext) MethodNotFoundException(com.walmartlabs.concord.runtime.v2.runner.el.MethodNotFoundException) TaskCallInterceptor(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor) MethodNotFoundException(com.walmartlabs.concord.runtime.v2.runner.el.MethodNotFoundException)

Aggregations

Expression (com.walmartlabs.concord.runtime.v2.model.Expression)1 Step (com.walmartlabs.concord.runtime.v2.model.Step)1 MethodNotFoundException (com.walmartlabs.concord.runtime.v2.runner.el.MethodNotFoundException)1 TaskCallInterceptor (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor)1 CallContext (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor.CallContext)1 Task (com.walmartlabs.concord.runtime.v2.sdk.Task)1