use of org.mule.runtime.config.internal.SpringConfigurationComponentLocator in project mule by mulesoft.
the class BeanDefinitionFactory method resolveComponent.
private BeanDefinition resolveComponent(ComponentModel parentComponentModel, SpringComponentModel componentModel, BeanDefinitionRegistry registry, BiConsumer<ComponentModel, BeanDefinitionRegistry> componentDefinitionModelProcessor, SpringConfigurationComponentLocator componentLocator) {
if (isComponentIgnored(componentModel.getIdentifier())) {
return null;
}
if (!componentModel.isEnabled()) {
// Just register the location, for support of lazyInit scenarios
componentLocator.addComponentLocation(componentModel.getComponentLocation());
return null;
}
resolveComponentBeanDefinition(parentComponentModel, componentModel);
componentDefinitionModelProcessor.accept(componentModel, registry);
// TODO MULE-9638: Once we migrate all core definitions we need to define a mechanism for customizing
// how core constructs are processed.
processMuleConfiguration(componentModel, registry);
processMuleSecurityManager(componentModel, registry);
processRaiseError(componentModel);
componentBuildingDefinitionRegistry.getBuildingDefinition(componentModel.getIdentifier()).ifPresent(componentBuildingDefinition -> {
if ((componentModel.getType() != null) && Component.class.isAssignableFrom(componentModel.getType())) {
addAnnotation(ANNOTATION_NAME, componentModel.getIdentifier(), componentModel);
// We need to use a mutable map since spring will resolve the properties placeholder present in the value if needed
// and it will be done by mutating the same map.
addAnnotation(ANNOTATION_PARAMETERS, new HashMap<>(componentModel.getParameters()), componentModel);
// add any error mappings if present
List<ComponentModel> errorMappingComponents = componentModel.getInnerComponents().stream().filter(innerComponent -> ERROR_MAPPING_IDENTIFIER.equals(innerComponent.getIdentifier())).collect(toList());
if (!errorMappingComponents.isEmpty()) {
addAnnotation(ANNOTATION_ERROR_MAPPINGS, errorMappingComponents.stream().map(innerComponent -> {
Map<String, String> parameters = innerComponent.getParameters();
ComponentIdentifier source = buildFromStringRepresentation(parameters.get(SOURCE_TYPE));
ErrorType errorType = errorTypeRepository.lookupErrorType(source).orElseThrow(() -> new MuleRuntimeException(createStaticMessage("Could not find error '%s'.", source)));
ErrorTypeMatcher errorTypeMatcher = new SingleErrorTypeMatcher(errorType);
ErrorType targetValue = resolveErrorType(parameters.get(TARGET_TYPE));
return new ErrorMapping(errorTypeMatcher, targetValue);
}).collect(toList()), componentModel);
}
componentLocator.addComponentLocation(componentModel.getComponentLocation());
}
});
addAnnotation(LOCATION_KEY, componentModel.getComponentLocation(), componentModel);
BeanDefinition beanDefinition = componentModel.getBeanDefinition();
return beanDefinition;
}
Aggregations