use of org.mule.runtime.extension.api.runtime.operation.ComponentExecutor in project mule by mulesoft.
the class ComponentMessageProcessor method createComponentExecutor.
private ComponentExecutor<T> createComponentExecutor() {
Map<String, Object> params = new HashMap<>();
LazyValue<Optional<ConfigurationInstance>> staticConfiguration = new LazyValue<>(this::getStaticConfiguration);
LazyValue<ValueResolvingContext> resolvingContext = new LazyValue<>(() -> {
CoreEvent initialiserEvent = null;
try {
initialiserEvent = getInitialiserEvent();
return from(initialiserEvent, staticConfiguration.get());
} finally {
if (initialiserEvent != null) {
((BaseEventContext) initialiserEvent.getContext()).success();
}
}
});
componentModel.getParameterGroupModels().stream().forEach(group -> {
if (group.getName().equals(DEFAULT_GROUP_NAME)) {
group.getParameterModels().stream().filter(p -> p.getModelProperty(FieldOperationParameterModelProperty.class).isPresent()).forEach(p -> {
ValueResolver<?> resolver = resolverSet.getResolvers().get(p.getName());
if (resolver != null) {
try {
params.put(getMemberName(p), resolveValue(resolver, resolvingContext.get()));
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
}
});
} else {
ParameterGroupDescriptor groupDescriptor = group.getModelProperty(ParameterGroupModelProperty.class).map(g -> g.getDescriptor()).orElse(null);
if (groupDescriptor == null) {
return;
}
List<ParameterModel> fieldParameters = getGroupsOfFieldParameters(group);
if (fieldParameters.isEmpty()) {
return;
}
ObjectBuilder groupBuilder = createFieldParameterGroupBuilder(groupDescriptor, fieldParameters);
try {
params.put(((Field) groupDescriptor.getContainer()).getName(), groupBuilder.build(resolvingContext.get()));
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
}
});
return getOperationExecutorFactory(componentModel).createExecutor(componentModel, params);
}
Aggregations