use of org.mule.runtime.config.internal.model.ComponentModel in project mule by mulesoft.
the class ComponentLocationVisitor method processOnErrorModel.
private DefaultComponentLocation processOnErrorModel(ComponentModel componentModel, DefaultComponentLocation parentComponentLocation, Optional<TypedComponentIdentifier> typedComponentIdentifier) {
ComponentModel parentComponentModel = componentModel.getParent();
int i = 0;
for (ComponentModel childComponent : parentComponentModel.getInnerComponents()) {
if (childComponent == componentModel) {
break;
}
i++;
}
return parentComponentLocation.appendLocationPart(String.valueOf(i), typedComponentIdentifier, componentModel.getConfigFileName(), componentModel.getLineNumber());
}
use of org.mule.runtime.config.internal.model.ComponentModel in project mule by mulesoft.
the class CollectionBeanDefinitionCreator method handleRequest.
@Override
boolean handleRequest(CreateBeanDefinitionRequest createBeanDefinitionRequest) {
SpringComponentModel componentModel = (SpringComponentModel) createBeanDefinitionRequest.getComponentModel();
ComponentBuildingDefinition componentBuildingDefinition = createBeanDefinitionRequest.getComponentBuildingDefinition();
ObjectTypeVisitor objectTypeVisitor = new ObjectTypeVisitor(componentModel);
componentBuildingDefinition.getTypeDefinition().visit(objectTypeVisitor);
if (Collection.class.isAssignableFrom(objectTypeVisitor.getType())) {
componentModel.setType(objectTypeVisitor.getType());
ManagedList<Object> managedList = new ManagedList<>();
for (ComponentModel innerComponent : componentModel.getInnerComponents()) {
SpringComponentModel innerSpringComp = (SpringComponentModel) innerComponent;
Object bean = innerSpringComp.getBeanDefinition() == null ? innerSpringComp.getBeanReference() : innerSpringComp.getBeanDefinition();
managedList.add(bean);
}
componentModel.setBeanDefinition(BeanDefinitionBuilder.genericBeanDefinition(objectTypeVisitor.getType()).addConstructorArgValue(managedList).getBeanDefinition());
return true;
}
return false;
}
use of org.mule.runtime.config.internal.model.ComponentModel 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));
}
use of org.mule.runtime.config.internal.model.ComponentModel in project mule by mulesoft.
the class MinimalApplicationModelGenerator method getMinimalModel.
/**
* Resolves the minimal set of {@link ComponentModel componentModels} for the component.
*
* @param location {@link Location} for the requested component to be enabled.
* @return the generated {@link ApplicationModel} with the minimal set of {@link ComponentModel}s required.
* @throws NoSuchComponentModelException if the location doesn't match to a component.
*/
public ApplicationModel getMinimalModel(Location location) {
ComponentModel requestedComponentModel = dependencyResolver.findRequiredComponentModel(location);
enableComponentDependencies(requestedComponentModel);
return dependencyResolver.getApplicationModel();
}
use of org.mule.runtime.config.internal.model.ComponentModel in project mule by mulesoft.
the class MinimalApplicationModelGenerator method enableParentComponentModels.
private void enableParentComponentModels(ComponentModel requestedComponentModel) {
ComponentModel parentModel = requestedComponentModel.getParent();
while (parentModel != null && parentModel.getParent() != null) {
parentModel.setEnabled(true);
parentModel = parentModel.getParent();
}
}
Aggregations