org.springframework.beans.factory.config.PropertyResourceConfigurer Java Examples

The following examples show how to use org.springframework.beans.factory.config.PropertyResourceConfigurer. 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: PropertySourceConfigurationSource.java    From conf4j with MIT License 5 votes vote down vote up
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;
}
 
Example #2
Source File: ConfigurationUtil.java    From A.CTable-Frame with Apache License 2.0 5 votes vote down vote up
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);
	}
}
 
Example #3
Source File: IntegrationTestConfiguration.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Bean
public static PropertyResourceConfigurer propertySourcesPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}