This method is called by setApplicationContext, which is called by Spring, when it sets the ApplicationContext to the controller. But if the controller is not running in an application context, I don't think that setApplicationContext will be called at all.
I don't remember how web applications treat the application context, but there's a reference
here which might help you.