com.alibaba.spring.util.PropertySourcesUtils Java Examples

The following examples show how to use com.alibaba.spring.util.PropertySourcesUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigurationBeanBindingRegistrar.java    From spring-context-support with Apache License 2.0 6 votes vote down vote up
private void registerConfigurationBeans(String prefix, Class<?> configClass, boolean multiple,
                                        boolean ignoreUnknownFields, boolean ignoreInvalidFields,
                                        BeanDefinitionRegistry registry) {

    Map<String, Object> configurationProperties = PropertySourcesUtils.getSubProperties(environment.getPropertySources(), environment, prefix);

    if (CollectionUtils.isEmpty(configurationProperties)) {
        if (log.isDebugEnabled()) {
            log.debug("There is no property for binding to configuration class [" + configClass.getName()
                    + "] within prefix [" + prefix + "]");
        }
        return;
    }

    Set<String> beanNames = multiple ? resolveMultipleBeanNames(configurationProperties) :
            singleton(resolveSingleBeanName(configurationProperties, configClass, registry));

    for (String beanName : beanNames) {
        registerConfigurationBean(beanName, configClass, multiple, ignoreUnknownFields, ignoreInvalidFields,
                configurationProperties, registry);
    }

    registerConfigurationBindingBeanPostProcessor(registry);
}
 
Example #2
Source File: NacosDiscoveryProperties.java    From spring-cloud-alibaba with Apache License 2.0 4 votes vote down vote up
private void enrichNacosDiscoveryProperties(Properties nacosDiscoveryProperties) {
	Map<String, Object> properties = PropertySourcesUtils
			.getSubProperties((ConfigurableEnvironment) environment, PREFIX);
	properties.forEach((k, v) -> nacosDiscoveryProperties.putIfAbsent(resolveKey(k),
			String.valueOf(v)));
}
 
Example #3
Source File: NacosConfigProperties.java    From spring-cloud-alibaba with Apache License 2.0 4 votes vote down vote up
private void enrichNacosConfigProperties(Properties nacosConfigProperties) {
	Map<String, Object> properties = PropertySourcesUtils
			.getSubProperties((ConfigurableEnvironment) environment, PREFIX);
	properties.forEach((k, v) -> nacosConfigProperties.putIfAbsent(resolveKey(k),
			String.valueOf(v)));
}
 
Example #4
Source File: ContentNegotiationManagerConfiguration.java    From spring-boot-web-support with GNU General Public License v3.0 3 votes vote down vote up
@Bean
public WebMvcConfigurer configurableContentNegotiationManagerWebMvcConfigurer(ConfigurableEnvironment environment) {

    Map<String, String> properties = new HashMap<String, String>();

    Map<String, Object> subProperties = PropertySourcesUtils.getSubProperties(environment.getPropertySources(),
            CONTENT_NEGOTIATION_MANAGER_PROPERTY_NAME_PREFIX);

    for (Map.Entry<String, Object> entry : subProperties.entrySet()) {
        properties.put(entry.getKey(), entry.getValue().toString());
    }

    return new ConfigurableContentNegotiationManagerWebMvcConfigurer(properties);

}