use of org.mule.runtime.api.util.LazyValue in project mule by mulesoft.
the class ReflectiveMethodComponentExecutor method getMethodArgumentResolver.
private LazyValue<ArgumentResolverDelegate> getMethodArgumentResolver(List<ParameterGroupModel> groups, Method method) {
return new LazyValue<>(() -> {
try {
MethodArgumentResolverDelegate resolver = new MethodArgumentResolverDelegate(groups, method);
initialiseIfNeeded(resolver, muleContext);
return resolver;
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage("Could not initialize argument resolver resolver"), e);
}
});
}
use of org.mule.runtime.api.util.LazyValue in project mule by mulesoft.
the class BackPressureContextArgumentResolver method resolve.
@Override
public LazyValue<BackPressureContext> resolve(ExecutionContext executionContext) {
return new LazyValue<>(() -> {
ExecutionContextAdapter ctx = (ExecutionContextAdapter) executionContext;
BackPressureAction action = (BackPressureAction) ctx.getVariable(BACK_PRESSURE_ACTION_CONTEXT_PARAM);
if (action == null) {
action = FAIL;
}
return new ImmutableBackPressureContext(ctx.getEvent(), action, callbackContextResolver.resolve(ctx).get());
});
}
use of org.mule.runtime.api.util.LazyValue in project mule by mulesoft.
the class VoidCallbackArgumentResolver method resolve.
@Override
public LazyValue<VoidCompletionCallback> resolve(ExecutionContext executionContext) {
return new LazyValue<>(() -> {
ExecutionContextAdapter adapter = (ExecutionContextAdapter) executionContext;
CompletionCallback completionCallback = (CompletionCallback) adapter.getVariable(COMPLETION_CALLBACK_CONTEXT_PARAM);
final CoreEvent event = adapter.getEvent();
return new VoidCompletionCallback() {
@Override
public void success() {
completionCallback.success(EventedResult.from(event));
}
@Override
public void error(Throwable e) {
completionCallback.error(e);
}
};
});
}
use of org.mule.runtime.api.util.LazyValue in project mule by mulesoft.
the class SourceResultArgumentResolver method resolve.
@Override
public LazyValue<SourceResult> resolve(ExecutionContext executionContext) {
return new LazyValue<>(() -> {
Error error = errorArgumentResolver.resolve(executionContext).get();
SourceCallbackContext callbackContext = callbackContextArgumentResolver.resolve(executionContext).get();
if (error == null) {
return success(callbackContext);
} else {
String errorIdentifier = error.getErrorType().getIdentifier();
return isErrorGeneratingErrorResponse(errorIdentifier) ? invocationError(error, callbackContext) : responseError(error, callbackContext);
}
});
}
use of org.mule.runtime.api.util.LazyValue in project mule by mulesoft.
the class CommonBeanDefinitionCreator method createBeanDefinitionBuilderFromObjectFactory.
private BeanDefinitionBuilder createBeanDefinitionBuilderFromObjectFactory(final SpringComponentModel componentModel, final ComponentBuildingDefinition componentBuildingDefinition) {
ObjectTypeVisitor objectTypeVisitor = new ObjectTypeVisitor(componentModel);
componentBuildingDefinition.getTypeDefinition().visit(objectTypeVisitor);
Class<?> objectFactoryType = componentBuildingDefinition.getObjectFactoryType();
Optional<Consumer<Object>> instanceCustomizationFunctionOptional;
Map<String, Object> customProperties = getTransformerCustomProperties(componentModel);
if (customProperties.isEmpty()) {
instanceCustomizationFunctionOptional = empty();
} else {
instanceCustomizationFunctionOptional = of(object -> injectSpringProperties(customProperties, object));
}
return rootBeanDefinition(objectFactoryClassRepository.getObjectFactoryClass(componentBuildingDefinition, objectFactoryType, objectTypeVisitor.getType(), new LazyValue<>(() -> componentModel.getBeanDefinition().isLazyInit()), instanceCustomizationFunctionOptional));
}
Aggregations