use of org.mule.runtime.config.internal.dsl.model.config.MapConfigurationPropertiesProvider in project mule by mulesoft.
the class ApplicationModel method createConfigurationAttributeResolver.
private void createConfigurationAttributeResolver(ArtifactConfig artifactConfig, Optional<ConfigurationProperties> parentConfigurationProperties, Map<String, String> deploymentProperties) {
EnvironmentPropertiesConfigurationProvider environmentPropertiesConfigurationProvider = new EnvironmentPropertiesConfigurationProvider();
ConfigurationPropertiesProvider globalPropertiesConfigurationAttributeProvider = createProviderFromGlobalProperties(artifactConfig);
DefaultConfigurationPropertiesResolver localResolver = new DefaultConfigurationPropertiesResolver(of(new DefaultConfigurationPropertiesResolver(of(new DefaultConfigurationPropertiesResolver(empty(), environmentPropertiesConfigurationProvider)), globalPropertiesConfigurationAttributeProvider)), environmentPropertiesConfigurationProvider);
List<ConfigurationPropertiesProvider> configConfigurationPropertiesProviders = getConfigurationPropertiesProvidersFromComponents(artifactConfig, localResolver);
FileConfigurationPropertiesProvider externalPropertiesConfigurationProvider = new FileConfigurationPropertiesProvider(externalResourceProvider, "External files");
Optional<ConfigurationPropertiesResolver> parentConfigurationPropertiesResolver = of(localResolver);
if (parentConfigurationProperties.isPresent()) {
parentConfigurationPropertiesResolver = of(new DefaultConfigurationPropertiesResolver(empty(), new ConfigurationPropertiesProvider() {
@Override
public Optional<ConfigurationProperty> getConfigurationProperty(String configurationAttributeKey) {
return parentConfigurationProperties.get().resolveProperty(configurationAttributeKey).map(value -> new DefaultConfigurationProperty(parentConfigurationProperties, configurationAttributeKey, value));
}
@Override
public String getDescription() {
return "Domain properties";
}
}));
}
if (!configConfigurationPropertiesProviders.isEmpty()) {
CompositeConfigurationPropertiesProvider configurationAttributesProvider = new CompositeConfigurationPropertiesProvider(configConfigurationPropertiesProviders);
parentConfigurationPropertiesResolver = of(new DefaultConfigurationPropertiesResolver(parentConfigurationPropertiesResolver, configurationAttributesProvider));
}
DefaultConfigurationPropertiesResolver globalPropertiesConfigurationPropertiesResolver = new DefaultConfigurationPropertiesResolver(parentConfigurationPropertiesResolver, globalPropertiesConfigurationAttributeProvider);
DefaultConfigurationPropertiesResolver systemPropertiesResolver = new DefaultConfigurationPropertiesResolver(of(globalPropertiesConfigurationPropertiesResolver), environmentPropertiesConfigurationProvider);
DefaultConfigurationPropertiesResolver externalPropertiesResolver = new DefaultConfigurationPropertiesResolver(of(systemPropertiesResolver), externalPropertiesConfigurationProvider);
if (deploymentProperties.isEmpty()) {
this.configurationProperties = new PropertiesResolverConfigurationProperties(externalPropertiesResolver);
} else {
this.configurationProperties = new PropertiesResolverConfigurationProperties(new DefaultConfigurationPropertiesResolver(of(externalPropertiesResolver), new MapConfigurationPropertiesProvider(deploymentProperties, "Deployment properties")));
}
}
Aggregations