I knew Spring supports two types of injection - setter and constructor. I had
also heard of a third type called method injection. But having never
come across a use case for the same, I pretty much ignored it. Until I gave an interview.
All was going well until this question came along:
"You have a singleton bean. Is there a way to inject a new bean X into this class whenever you call the getX property of this bean ?"
I was pretty flummoxed. Later on I hunted on the web and came across this post by Rod Johnson.
The below post is an adaption from the same to focus on the interviewer's question.
All was going well until this question came along:
"You have a singleton bean. Is there a way to inject a new bean X into this class whenever you call the getX property of this bean ?"
I was pretty flummoxed. Later on I hunted on the web and came across this post by Rod Johnson.
The below post is an adaption from the same to focus on the interviewer's question.