In an Spring Application it is possible to retrieve all (?) Beans with applicationContext.getBeansOfType(Object.class)
. This is of course only possible, after all Beans have been created.
So, if I call this method in the constructor of a Bean, I have to be lucky, to be the last Bean to be created, to have access to all of them.
As far as I understand the life cycle of Spring Beans, there is a phase in which BeanDefinitions are created, before the Beans are initialized.
- How is it possible to retrive all created BeanDefinitions in the constructor of a Bean?
- Can I also retrive the types (as
Class
) of those BeanDefinitions? The type BeanDefinition seems to only provide the "current bean class name of this bean definition".
Or is the only way to get those types after all Beans have been constructed (e.g. @PostConstruct
)?