I am aware of the bean post processor and it's working but I am not sure how it will helps us in real world application. what should be there inside the below define method in real application could it be
1 Some configuration Code?
2 Some validation code for bean ?
public class MyBeanInitProcessor implements BeanPostProcessor{
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
System.out.println("before initialization: "+beanName);
return bean;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
System.out.println("after initialization: "+beanName);
return bean;
}
}
In most real-world applications, you won't be interacting with them directly. Spring provides 28 implementations out of the box that handle standard functions like autowiring and applying AOP advice. You use them indirectly by using the standard Spring features such as applying validation annotations on a method parameter, which applies MethodValidationPostProcessor
, or making method calls @Async
, which applies AsyncAnnotationBeanPostProcessor
.