I want to inject prototype beans into a singleton factory. we're considering 4 options, and would like someone to emphasize the differences.
Sorted according to my personal preference:
- use
@lookupmethod annotation (we use code based configuration). @Autowireda Provider (one for each bean) andget()for each type.- Provide static access to
ApplicationContext.getBean()from anywhere in the application, andgetBean()from there. - inject ApplicationContext, and
getBean().
I know getBean() is a bad practice, but for some reason, I see many answers directing this way.
(whats the big difference between options 2 & 3 ?)