use of org.mule.runtime.module.extension.internal.loader.java.property.SourceCallbackModelProperty in project mule by mulesoft.
the class SourceModelLoaderDelegate method declareSourceCallback.
private void declareSourceCallback(SourceElement sourceType, SourceDeclarer source) {
final Optional<MethodElement> onResponseMethod = sourceType.getOnResponseMethod();
final Optional<MethodElement> onErrorMethod = sourceType.getOnErrorMethod();
final Optional<MethodElement> onTerminateMethod = sourceType.getOnTerminateMethod();
final Optional<MethodElement> onBackPressureMethod = sourceType.getOnBackPressureMethod();
// TODO: MULE-9220 add syntax validator to check that none of these use @UseConfig or @Connection
declareSourceCallbackParameters(source, onResponseMethod, source::onSuccess);
declareSourceCallbackParameters(source, onErrorMethod, source::onError);
declareSourceCallbackParameters(source, onTerminateMethod, source::onTerminate);
declareSourceCallbackParameters(source, onBackPressureMethod, source::onBackPressure);
source.withModelProperty(new SourceCallbackModelProperty(getMethod(onResponseMethod), getMethod(onErrorMethod), getMethod(onTerminateMethod), getMethod(onBackPressureMethod)));
}
use of org.mule.runtime.module.extension.internal.loader.java.property.SourceCallbackModelProperty in project mule by mulesoft.
the class SourceAdapter method doCreateCompletionHandler.
private SourceCompletionHandlerFactory doCreateCompletionHandler(SourceCallbackModelProperty modelProperty) {
SourceCallbackExecutor onSuccessExecutor;
SourceCallbackExecutor onErrorExecutor;
SourceCallbackExecutor onTerminateExecutor;
SourceCallbackExecutor onBackPressureExecutor;
if (source instanceof SourceWrapper) {
SourceWrapper wrapper = (SourceWrapper) source;
onSuccessExecutor = getMethodExecutor(modelProperty.getOnSuccessMethod(), modelProperty, wrapper::onSuccess);
onErrorExecutor = getMethodExecutor(modelProperty.getOnErrorMethod(), modelProperty, wrapper::onError);
onTerminateExecutor = getMethodExecutor(modelProperty.getOnTerminateMethod(), modelProperty, wrapper::onTerminate);
onBackPressureExecutor = getMethodExecutor(modelProperty.getOnBackPressureMethod(), modelProperty, wrapper::onBackPressure);
} else {
onSuccessExecutor = getMethodExecutor(modelProperty.getOnSuccessMethod(), modelProperty);
onErrorExecutor = getMethodExecutor(modelProperty.getOnErrorMethod(), modelProperty);
onTerminateExecutor = getMethodExecutor(modelProperty.getOnTerminateMethod(), modelProperty);
onBackPressureExecutor = getMethodExecutor(modelProperty.getOnBackPressureMethod(), modelProperty);
}
return context -> new DefaultSourceCompletionHandler(onSuccessExecutor, onErrorExecutor, onTerminateExecutor, onBackPressureExecutor, context);
}
Aggregations