Search in sources :

Example 6 with ComponentModel

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());
}
Also used : ComponentModel(org.mule.runtime.config.internal.model.ComponentModel)

Example 7 with ComponentModel

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;
}
Also used : SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) ManagedList(org.springframework.beans.factory.support.ManagedList) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor)

Example 8 with ComponentModel

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));
}
Also used : BeanDefinitionPostProcessor(org.mule.runtime.config.privileged.dsl.BeanDefinitionPostProcessor) Optional.of(java.util.Optional.of) CursorStreamProvider(org.mule.runtime.api.streaming.bytes.CursorStreamProvider) SecurityFilter(org.mule.runtime.core.api.security.SecurityFilter) MuleApplicationClassLoader.resolveContextArtifactPluginClassLoaders(org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader.resolveContextArtifactPluginClassLoaders) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) ROOT_MACRO_EXPANDED_FLOW_CONTAINER_NAME(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModuleModel.ROOT_MACRO_EXPANDED_FLOW_CONTAINER_NAME) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) MULE_PROPERTY_IDENTIFIER(org.mule.runtime.config.internal.model.ApplicationModel.MULE_PROPERTY_IDENTIFIER) Collectors.toMap(java.util.stream.Collectors.toMap) SecurityFilterMessageProcessor(org.mule.runtime.core.privileged.processor.SecurityFilterMessageProcessor) Map(java.util.Map) CUSTOM_TRANSFORMER_IDENTIFIER(org.mule.runtime.config.internal.model.ApplicationModel.CUSTOM_TRANSFORMER_IDENTIFIER) Pair(org.mule.runtime.api.util.Pair) ANNOTATIONS_ELEMENT_IDENTIFIER(org.mule.runtime.config.internal.model.ApplicationModel.ANNOTATIONS_ELEMENT_IDENTIFIER) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) SPRING_PROTOTYPE_OBJECT(org.mule.runtime.config.internal.dsl.spring.BeanDefinitionFactory.SPRING_PROTOTYPE_OBJECT) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ProcessingStrategy(org.mule.runtime.core.api.processor.strategy.ProcessingStrategy) XmlCustomAttributeHandler(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) List(java.util.List) Optional(java.util.Optional) BeanUtils.copyProperty(org.apache.commons.beanutils.BeanUtils.copyProperty) QName(javax.xml.namespace.QName) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Optional.empty(java.util.Optional.empty) XmlCustomAttributeHandler.from(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.from) DefaultMessageProcessorChainBuilder(org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder) BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) BeanDefinitionBuilder.genericBeanDefinition(org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition) HashMap(java.util.HashMap) ANNOTATIONS_PROPERTY_NAME(org.mule.runtime.api.component.Component.ANNOTATIONS_PROPERTY_NAME) XmlMetadataAnnotations(org.mule.runtime.config.internal.parsers.XmlMetadataAnnotations) ArrayList(java.util.ArrayList) Component(org.mule.runtime.api.component.Component) Node(org.w3c.dom.Node) ServiceConfigurationError(java.util.ServiceConfigurationError) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) ModuleOperationMessageProcessorChainFactoryBean(org.mule.runtime.config.internal.factories.ModuleOperationMessageProcessorChainFactoryBean) Collections.emptyMap(java.util.Collections.emptyMap) MULE_PROPERTIES_IDENTIFIER(org.mule.runtime.config.internal.model.ApplicationModel.MULE_PROPERTIES_IDENTIFIER) PropertyComponentUtils.getPropertyValueFromPropertyComponent(org.mule.runtime.config.internal.dsl.spring.PropertyComponentUtils.getPropertyValueFromPropertyComponent) LocationExecutionContextProvider.addMetadataAnnotationsFromXml(org.mule.runtime.core.privileged.execution.LocationExecutionContextProvider.addMetadataAnnotationsFromXml) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor) AbstractComponent(org.mule.runtime.api.component.AbstractComponent) Consumer(java.util.function.Consumer) LazyValue(org.mule.runtime.api.util.LazyValue) Element(org.w3c.dom.Element) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) BeanDefinitionBuilder.rootBeanDefinition(org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) LazyValue(org.mule.runtime.api.util.LazyValue) Consumer(java.util.function.Consumer) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor)

Example 9 with ComponentModel

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();
}
Also used : ComponentModel(org.mule.runtime.config.internal.model.ComponentModel)

Example 10 with ComponentModel

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();
    }
}
Also used : ComponentModel(org.mule.runtime.config.internal.model.ComponentModel)

Aggregations

ComponentModel (org.mule.runtime.config.internal.model.ComponentModel)41 HashMap (java.util.HashMap)14 List (java.util.List)13 Map (java.util.Map)13 SpringComponentModel (org.mule.runtime.config.internal.dsl.model.SpringComponentModel)13 Optional (java.util.Optional)11 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)11 Set (java.util.Set)9 ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)9 String.format (java.lang.String.format)8 ArrayList (java.util.ArrayList)8 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)8 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)8 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)8 Collections.emptyMap (java.util.Collections.emptyMap)7 GlobalElementComponentModelModelProperty (org.mule.runtime.config.internal.dsl.model.extension.xml.property.GlobalElementComponentModelModelProperty)7 Optional.of (java.util.Optional.of)6 Collectors (java.util.stream.Collectors)6 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)6 OperationComponentModelModelProperty (org.mule.runtime.config.internal.dsl.model.extension.xml.property.OperationComponentModelModelProperty)6