-1

A bean implementing BeanPostProcessor is called when all bean definitions will have been loaded, but no beans will have been instantiated yet

BeanPostprocessor is executed after the bean object is created, as it can be executed before init() and after init().

Is BeanPostProcessor postProcessAfterInitialization needed only to work with proxy?

UPD: what we need 2 methods postProcessBeforeInitialization & postProcessAfterInitialization for? Why not just one postProcessInitialization ?

J.J. Beam
  • 2,612
  • 2
  • 26
  • 55
  • I don't understand your quesiton, please elaborate and make it more clear. – M. Deinum Jan 19 '22 at 07:04
  • what we need 2 methods postProcessBeforeInitialization & postProcessAfterInitialization for? Why not just one? – J.J. Beam Jan 19 '22 at 17:37
  • The `BeanFactoryPostProcessor` only has a single method. You are probably confusing the `BeanFactoryPostProcessor` and the `BeanPostProcessor`. IMHO the question is answered in the [javadoc](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/config/BeanPostProcessor.html) of the last class (both the classlevel and method level). – M. Deinum Jan 20 '22 at 06:13

1 Answers1

0
@Nullable
default Object postProcessAfterInitialization(Object bean,
                                                        String beanName)
                                                 throws BeansException

Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

J.J. Beam
  • 2,612
  • 2
  • 26
  • 55