Rahul Shivsharan wrote:i didn't understood the first point,
Are you saying that as i'm using BeanFactory thats the reason postProcessesAfterinitialisation() and destroy() methods are not getting called ?
Can you explain me , please
The BeanFactory is the older way to use Spring, it used to be the Spring Container that was used. Then Spring introduced the ApplicationContext, which added new features including more steps into the Initialization Phase, which is what you are looking at. The BeanPostProcessor step was not part of the BeanFactory initialization lifecycle. But it is with ApplicationContext. ApplicationContext is a Bean Factory plus more.
The destroy method only gets called when you call close() on the ApplicationContext, and that method is only on the ConfigurableApplicationContext interface, so you would have to cast your ApplicationContext to that type, then call close().
Mark