org.springframework.beans.factory.config.PropertyResourceConfigurer#org.springframework.core.io.support.PropertiesLoaderSupport源码实例Demo

下面列出了org.springframework.beans.factory.config.PropertyResourceConfigurer#org.springframework.core.io.support.PropertiesLoaderSupport 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 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);
	}
}