Retrieving beans by Configuration Object
Hi,
Thanks for providing JavaConfig. I realy like its type-safe way to use Spring.
Retrieving beans through their class is well documentend but I've wondered wheter it is also possible to retrieve beans by first getting the Configuration object from the ApplicationContext and than calling the definition method on the Configuration object to get to the beans.
I find this the most 'javaish' way, because it looks like invoking a singleton-method and the retrieve is both type-save and unambigious, refactorable.
This seems to work in my trival test-code based on the introduction example:
Code:
public static void main(String... args) {
JavaConfigApplicationContext context =
new JavaConfigApplicationContext(ApplicationConfig.class);
ApplicationConfig applicationConfig =
context.getBean(ApplicationConfig.class);
TransferService transferService =
applicationConfig.transferService
transferService.transfer .......
}
My question is wheter this realy works like getting the bean directly through the ApplicationContext or are there any other disadvantages, because it is not documented at all.
Thanks,
Christian
.