use of ru.fix.completable.reactor.runtime.internal.dsl.CRProcessorDescription in project completable-reactor by ru-fix.
the class ReactorGraphExecutionBuilder method invokeProcessorHandlingMethod.
private CompletableFuture<?> invokeProcessorHandlingMethod(CRReactorGraph.ProcessingItemInfo processorInfo, CRProcessingItem processingItem, Object payload) {
CRProcessorDescription description = processorInfo.getDescription();
try {
Object param1 = null;
Object param2 = null;
Object param3 = null;
Object param4 = null;
Object param5 = null;
Object param6 = null;
Object param7 = null;
if (description.getArg1() != null) {
param1 = description.getArg1().apply(payload);
if (description.isCopyArg1()) {
param1 = threadsafeCopyMaker.makeThreadsafeCopy(param1);
}
}
if (description.getArg2() != null) {
param2 = description.getArg2().apply(payload);
if (description.isCopyArg2()) {
param2 = threadsafeCopyMaker.makeThreadsafeCopy(param2);
}
}
if (description.getArg3() != null) {
param3 = description.getArg3().apply(payload);
if (description.isCopyArg3()) {
param3 = threadsafeCopyMaker.makeThreadsafeCopy(param3);
}
}
if (description.getArg4() != null) {
param4 = description.getArg4().apply(payload);
if (description.isCopyArg4()) {
param4 = threadsafeCopyMaker.makeThreadsafeCopy(param4);
}
}
if (description.getArg5() != null) {
param5 = description.getArg5().apply(payload);
if (description.isCopyArg5()) {
param5 = threadsafeCopyMaker.makeThreadsafeCopy(param5);
}
}
if (description.getArg6() != null) {
param6 = description.getArg6().apply(payload);
if (description.isCopyArg6()) {
param6 = threadsafeCopyMaker.makeThreadsafeCopy(param6);
}
}
if (description.getArg7() != null) {
param7 = description.getArg7().apply(payload);
if (description.isCopyArg7()) {
param7 = threadsafeCopyMaker.makeThreadsafeCopy(param7);
}
}
if (description.getHandler0() != null) {
return (CompletableFuture) description.getHandler0().handle();
} else if (description.getHandler1() != null) {
return (CompletableFuture) description.getHandler1().handle(param1);
} else if (description.getHandler2() != null) {
return (CompletableFuture) description.getHandler2().handle(param1, param2);
} else if (description.getHandler3() != null) {
return (CompletableFuture) description.getHandler3().handle(param1, param2, param3);
} else if (description.getHandler4() != null) {
return (CompletableFuture) description.getHandler4().handle(param1, param2, param3, param4);
} else if (description.getHandler5() != null) {
return (CompletableFuture) description.getHandler5().handle(param1, param2, param3, param4, param5);
} else if (description.getHandler6() != null) {
return (CompletableFuture) description.getHandler6().handle(param1, param2, param3, param4, param5, param6);
} else if (description.getHandler7() != null) {
return (CompletableFuture) description.getHandler7().handle(param1, param2, param3, param4, param5, param6, param7);
} else {
CompletableFuture result = new CompletableFuture();
result.completeExceptionally(new IllegalArgumentException(String.format("There is no handler in processor %s for payload %s %s", processingItem.getDebugName(), payload.getClass(), debugSerializer.dumpObject(payload))));
return result;
}
} catch (Exception exc) {
CompletableFuture result = new CompletableFuture();
result.completeExceptionally(new IllegalArgumentException(String.format("Exception during handling in processor %s for payload %s %s", processingItem.getDebugName(), payload.getClass(), debugSerializer.dumpObject(payload)), exc));
return result;
}
}
Aggregations