Skip to content

Instantly share code, notes, and snippets.

@vvasabi
Created March 26, 2014 18:55
Show Gist options
  • Save vvasabi/9790659 to your computer and use it in GitHub Desktop.
Save vvasabi/9790659 to your computer and use it in GitHub Desktop.
Instead of being able to override properties in any beans, this variant of PropertyOverrideConfigurer restricts property overriding to just 1 specified bean.
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyOverrideConfigurer;
public class BeanPropertyOverrideConfigurer extends PropertyOverrideConfigurer {
private String beanName;
public String getBeanName() {
return beanName;
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
@Override
protected void processKey(ConfigurableListableBeanFactory factory, String key, String value)
throws BeansException {
applyPropertyValue(factory, beanName, key, value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment