Search in sources :

Example 41 with ComponentModel

use of org.mule.runtime.config.internal.model.ComponentModel in project mule by mulesoft.

the class ComponentModelReader method extractComponentDefinitionModel.

public ComponentModel extractComponentDefinitionModel(ConfigLine configLine, String configFileName) {
    String namespace = configLine.getNamespace() == null ? CORE_PREFIX : configLine.getNamespace();
    ComponentModel.Builder builder = new ComponentModel.Builder().setIdentifier(builder().namespace(namespace).name(configLine.getIdentifier()).build()).setTextContent(resolveValueIfIsPlaceHolder(configLine.getTextContent())).setConfigFileName(configFileName).setLineNumber(configLine.getLineNumber());
    to(builder).addNode(from(configLine).getNode());
    for (SimpleConfigAttribute simpleConfigAttribute : configLine.getConfigAttributes().values()) {
        builder.addParameter(simpleConfigAttribute.getName(), resolveValueIfIsPlaceHolder(simpleConfigAttribute.getValue()), simpleConfigAttribute.isValueFromSchema());
    }
    List<ComponentModel> componentModels = configLine.getChildren().stream().map(childConfigLine -> extractComponentDefinitionModel(childConfigLine, configFileName)).collect(Collectors.toList());
    componentModels.stream().forEach(componentDefinitionModel -> builder.addChildComponentModel(componentDefinitionModel));
    ConfigLine parent = configLine.getParent();
    if (parent != null && isConfigurationTopComponent(parent)) {
        builder.markAsRootComponent();
    }
    ComponentModel componentModel = builder.build();
    for (ComponentModel innerComponentModel : componentModel.getInnerComponents()) {
        innerComponentModel.setParent(componentModel);
    }
    return componentModel;
}
Also used : Properties(java.util.Properties) XmlCustomAttributeHandler.from(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.from) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) SimpleConfigAttribute(org.mule.runtime.config.api.dsl.processor.SimpleConfigAttribute) MULE_ROOT_ELEMENT(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_ROOT_ELEMENT) MULE_DOMAIN_ROOT_ELEMENT(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_DOMAIN_ROOT_ELEMENT) Collectors(java.util.stream.Collectors) ConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.ConfigurationPropertiesResolver) XmlCustomAttributeHandler.to(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler.to) POLICY_ROOT_ELEMENT(org.mule.runtime.config.internal.model.ApplicationModel.POLICY_ROOT_ELEMENT) List(java.util.List) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) ComponentIdentifier.builder(org.mule.runtime.api.component.ComponentIdentifier.builder) SimpleConfigAttribute(org.mule.runtime.config.api.dsl.processor.SimpleConfigAttribute) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine)

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