org.springframework.context.support.PropertySourcesPlaceholderConfigurer#getAppliedPropertySources ( )源码实例Demo

下面列出了org.springframework.context.support.PropertySourcesPlaceholderConfigurer#getAppliedPropertySources ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public PropertySources getPropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        return configurer.getAppliedPropertySources();
    }
    MutablePropertySources sources = extractEnvironmentPropertySources();
    if (sources != null) {
        return sources;
    }
    throw new IllegalStateException("Unable to obtain PropertySources from "
            + "PropertySourcesPlaceholderConfigurer or Environment");
}
 
源代码2 项目: eagle   文件: EagleBeanFactoryPostProcessor.java
private PropertySources deducePropertySources(DefaultListableBeanFactory beanFactory) {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer(beanFactory);
    if (configurer != null) {
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }
    if (this.environment instanceof ConfigurableEnvironment) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
                .getPropertySources();
        return new FlatPropertySources(propertySources);
    }
    return new MutablePropertySources();
}
 
public static PropertySources getPropertySources(DefaultListableBeanFactory beanFactory) {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer(beanFactory);
    if (configurer != null) {
        return configurer.getAppliedPropertySources();
    }
    MutablePropertySources sources = extractEnvironmentPropertySources(beanFactory);
    if (sources != null) {
        return sources;
    }
    throw new IllegalStateException("Unable to obtain PropertySources from "
                                            + "PropertySourcesPlaceholderConfigurer or Environment");
}