BeanFactoryPostProcessor is an interface that allows to execute code before the bean factory (or application context) is initialized.
public class BeanFactoryPostProcessorImpl implements BeanFactoryPostProcessor { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory clbf) throws BeansException { // Do something } }
The order of execution is:
1) The BeanFactoryPostProcessor implementation is first called
2) The BeanFactory or ApplicationContext is initialized
3) The bean singletons are instantiated.
* * *
PropertyPlaceholderConfigurer is an example of a Spring class that implements this feature. It loads a property file making the values available to the application context.
<bean id="course" class="org.davis.Course"> <property name="teacher" value="${school.teacher.name}"/> </bean> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="courseInfo" value="course.properties"/> </bean>
Here's the property file (in the same path as the xml configuration file):
school.teacher.name=Ale
Copyright © 2013 Welcome to the website of Davis Fiore. All Rights Reserved.