'This is done by accessing the ApplicationContext’s BeanFactory through the getBeanFactory() method, which returns the DefaultListableBeanFactory implementation.'
It seems there is not method getBeanFactory()
presented in ApplicationContext
, not only that even after considering all it's sub classes there is not such method. but there indeed is public method to obtain BeanFactory
but through ConfigurableApplicationContext
.
Comment From: snicoll
It seems there is not method getBeanFactory() presented in ApplicationContext
Correct. However, your quote is missing an important bit:
the ApplicationContext implementations also permit the registration of existing objects that are created outside the container (by users).
"implementations' is very important here. It also stresses the fact that this isn't a first level use case, a bit later:
However, typical applications work solely with beans defined through regular bean definition metadata.
So in short. You can't do that via ApplicationContext
and you need to rely on a particular implementation to access these methods. This is done on purpose as we don't believe this to be a standard use case.