Problem: If we will inject the prototype bean into singleton bean; by default it will be singleton i.e. it will not behaving like prototype bean.
Resolve using Interface ObjectFactory:
Lookup Method injection
The Spring Framework implements method injection by using CGLIB library to generate dynamically a subclass that overrides the method. So for the method to be overridden, we have to define that method in the class and either provide a dummy implementation for it or make it abstract.
Making a method abstract implies that class also has to be made abstract which will make it difficult to unit test. So providing a dummy implementation is a better choice.
Whenever we define a bean with lookup methods, spring creates a subclass of the bean and overrides those methods which are marked as lookup-methods and this sub classed bean gets registered into the context. The subclass delegates all the non-lookup methods to the original class.