类org.springframework.beans.factory.config.PropertyResourceConfigurer源码实例Demo

下面列出了怎么用org.springframework.beans.factory.config.PropertyResourceConfigurer的API类实例代码及写法,或者点击链接到github查看源代码。

private List<PropertySourcesPlaceholderConfigurer> getAllPropertySourcesPlaceholderConfigurers() {
    if (!(this.beanFactory instanceof ListableBeanFactory)) {
        return emptyList();
    }

    ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
    // take care not to cause early instantiation of flattenedPropertySources FactoryBeans
    Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory
            .getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false, false);
    List<PropertySourcesPlaceholderConfigurer> configurers = new ArrayList<>(beans.values());
    configurers.sort(comparingInt(PropertyResourceConfigurer::getOrder));

    return configurers;
}
 
源代码2 项目: A.CTable-Frame   文件: ConfigurationUtil.java
private void initProperties() {
	
	properties = new Properties();
	try {
		String[] postProcessorNames = applicationContext.getBeanNamesForType(BeanFactoryPostProcessor.class, true,
				true);
		for (String ppName : postProcessorNames) {
			BeanFactoryPostProcessor beanProcessor = applicationContext.getBean(ppName,
					BeanFactoryPostProcessor.class);
			if (beanProcessor instanceof PropertyResourceConfigurer) {
				PropertyResourceConfigurer propertyResourceConfigurer = (PropertyResourceConfigurer) beanProcessor;
				Method mergeProperties = PropertiesLoaderSupport.class.getDeclaredMethod("mergeProperties");
				mergeProperties.setAccessible(true);
				Properties props = (Properties) mergeProperties.invoke(propertyResourceConfigurer);

				// get the method convertProperties
				// in class PropertyResourceConfigurer
				Method convertProperties = PropertyResourceConfigurer.class.getDeclaredMethod("convertProperties",
						Properties.class);
				// convert properties
				convertProperties.setAccessible(true);
				convertProperties.invoke(propertyResourceConfigurer, props);

				properties.putAll(props);
			}
		}

	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
源代码3 项目: cloudbreak   文件: IntegrationTestConfiguration.java
@Bean
public static PropertyResourceConfigurer propertySourcesPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}
 
 同包方法