Search in sources :

Example 1 with ComponentModelReader

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

the class ApplicationModel method convertConfigFileToComponentModel.

private void convertConfigFileToComponentModel(ArtifactConfig artifactConfig) {
    List<ConfigFile> configFiles = artifactConfig.getConfigFiles();
    ComponentModelReader componentModelReader = new ComponentModelReader(configurationProperties.getConfigurationPropertiesResolver());
    configFiles.stream().forEach(configFile -> {
        ComponentModel componentModel = componentModelReader.extractComponentDefinitionModel(configFile.getConfigLines().get(0), configFile.getFilename());
        if (muleComponentModels.isEmpty()) {
            muleComponentModels.add(componentModel);
        } else {
            // Only one componentModel as Root should be set, therefore componentModel is merged
            final ComponentModel rootComponentModel = muleComponentModels.get(0);
            muleComponentModels.set(0, new ComponentModel.Builder(rootComponentModel).merge(componentModel).build());
        }
    });
}
Also used : ComponentModelReader(org.mule.runtime.config.internal.dsl.model.ComponentModelReader) ConfigFile(org.mule.runtime.config.api.dsl.processor.ConfigFile)

Example 2 with ComponentModelReader

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

the class XmlExtensionLoaderDelegate method getModuleComponentModel.

private ComponentModel getModuleComponentModel(URL resource, Document moduleDocument) {
    XmlApplicationParser xmlApplicationParser = new XmlApplicationParser(new SpiServiceRegistry(), singletonList(currentThread().getContextClassLoader()));
    Optional<ConfigLine> parseModule = xmlApplicationParser.parse(moduleDocument.getDocumentElement());
    if (!parseModule.isPresent()) {
        // This happens in org.mule.runtime.config.dsl.processor.xml.XmlApplicationParser.configLineFromElement()
        throw new IllegalArgumentException(format("There was an issue trying to read the stream of '%s'", resource.getFile()));
    }
    ComponentModelReader componentModelReader = new ComponentModelReader(new DefaultConfigurationPropertiesResolver(empty(), new EnvironmentPropertiesConfigurationProvider()));
    return componentModelReader.extractComponentDefinitionModel(parseModule.get(), modulePath);
}
Also used : EnvironmentPropertiesConfigurationProvider(org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider) XmlApplicationParser(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationParser) ComponentModelReader(org.mule.runtime.config.internal.dsl.model.ComponentModelReader) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry)

Aggregations

ComponentModelReader (org.mule.runtime.config.internal.dsl.model.ComponentModelReader)2 ConfigFile (org.mule.runtime.config.api.dsl.processor.ConfigFile)1 ConfigLine (org.mule.runtime.config.api.dsl.processor.ConfigLine)1 XmlApplicationParser (org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationParser)1 DefaultConfigurationPropertiesResolver (org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver)1 EnvironmentPropertiesConfigurationProvider (org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider)1 SpiServiceRegistry (org.mule.runtime.core.api.registry.SpiServiceRegistry)1