BeanPostProcessor are special beans that are created before any other (regular) beans are created.
postProcessBeforeInitialization will
not be applied on the BeanPostProcessor itself but is called once for every other bean that is created.
In you example configuration if you remove the other bean
<bean id="holder" class="java.lang.String" />you will find that the sysout
will not contain
5. BeanPostProcessor#postProcessBeforeInitialization:7
7. BeanPostProcessor#postProcessAfterInitialization:8
Similarly if you add multiple beans you will see the post processor being called once for each Bean!
The rule,
If any of the beans implement the BeanPostProcessor interface, Spring calls
their postProcessBeforeInitialization() method.
7 If any beans implement the InitializingBean interface, Spring calls their
afterPropertiesSet() method. Similarly, if the bean was declared with an
init-method, then the specified initialization method will be called.
applies for regular beans not for bean that themselves implement the BeanPostProcessor interface.