use of org.finos.symphony.toolkit.workflow.java.resolvers.WorkflowResolvers in project spring-bot by finos.
the class AbstractHandlerExecutor method execute.
@Override
public void execute() throws Throwable {
ChatHandlerMethod hm = getOriginatingMapping().getHandlerMethod();
Method m = hm.getMethod();
Object o = hm.getBean();
WorkflowResolvers wr = buildWorkflowResolvers(action());
Object[] args = new Object[hm.getMethodParameters().length];
for (int i = 0; i < args.length; i++) {
MethodParameter mp = hm.getMethodParameters()[i];
Optional<Object> oo = wr.resolve(mp);
if (oo.isPresent()) {
args[i] = oo.get();
}
}
Object out;
try {
out = m.invoke(o, args);
} catch (InvocationTargetException ite) {
throw ite.getTargetException();
}
if (out instanceof Response) {
rh.accept((Response) out);
} else if (out instanceof Collection) {
for (Object object : (List<?>) out) {
if (object instanceof Response) {
rh.accept((Response) object);
} else {
Response r = convert(object);
if (r != null) {
rh.accept(r);
}
}
}
} else {
Response r = convert(out);
if (r != null) {
rh.accept(r);
}
}
}
Aggregations