The BeanFactoryPostProcessor is useful for custom config files targeted at system administrators that override bean properties configured in the application context.
Use this to execute code once the BeanFactory itself has been initialised.
Example
MyBeanFactoryPostProcessor
- Create the class MyBeanFactoryPostProcessor that implements BeanFactoryPostProcessor
- override the method postProcessBeanFactory
- print a message in the method
Configure the PostProcessor Bean
Declare the MyBeanFactoryPostProcessor in the spring.xml
<bean class="com.skills421.examples.spring. MyBeanFactoryPostProcessor" />
Now Spring will call this method as soon as the BeanFactory is created (ApplicationContext)
Then, all the beans will be instantiated.
We can use this to plug in additional functionality to change the behaviour of the Spring Framework – for example, to read a property file of values for the beans in the spring.xml