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());
}
});
}
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);
}
Aggregations