Skip to content

Instantly share code, notes, and snippets.

@vijedi
Created October 8, 2011 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijedi/1271808 to your computer and use it in GitHub Desktop.
Save vijedi/1271808 to your computer and use it in GitHub Desktop.
OrderedPropertyPlaceholderConfigurer
public class OrderedPropertyPlaceholderConfigurator implements Ordered, BeanFactoryPostProcessor {
private Resource[] locations;
private String systemPropertiesModeName;
private Boolean ignoreResourceNotFound;
private String propertyPlaceholderPrefix;
private String propertyPlaceholderSuffix;
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
configurer.setLocations(locations);
if(null != systemPropertiesModeName) {
configurer.setSystemPropertiesModeName(systemPropertiesModeName);
}
if(null != ignoreResourceNotFound) {
configurer.setIgnoreResourceNotFound(ignoreResourceNotFound);
}
if(null != propertyPlaceholderPrefix) {
configurer.setPlaceholderPrefix(propertyPlaceholderPrefix);
}
if(null != propertyPlaceholderSuffix) {
configurer.setPlaceholderSuffix(propertyPlaceholderSuffix);
}
configurer.postProcessBeanFactory(beanFactory);
}
/***********
* Setters would go here
***********/
@Override
public int getOrder() {
// Needs to run first, so order is 0
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment