To quote the spring reference: The ApplicationContextAware callback is invoked after population of normal bean properties but before an initialization callback such as InitializingBeans afterPropertiesSet or a custom init-method.
However, the setApplicationContext(..) is being called after the custom init method of one of my beans. Any idea how can change the flow as I want the CONTEXT to get loaded first and then the init-method should be called by Spring.
The resolution to this is instead of implementing the ApplicationContextAware, it is useful in this case to implement BeanFactoryAware and use the setBeanFactory(..) method.
This method gets called before any custom init methods are executed and in case if you need to use any bean in your init() method, you can do that.
Wow.. good to know. Is the behavior differrent if you use a init method vs afterPropertiesSets vs PostConstruct annotation. I might be wrong here, but I seem to recall the PostConstruct annotated function is called from a PostProcessor, whereas initmethod/afterPropertiesSet are called directly from spring.