|
What about the example used the manual to describe the "prototype" scope..
Does such a configuration (injecting prototypes into singletons using ctor/setter) actually *ever* make sense? I'm just curious if I'm missing some potential usage pattern. Hi Taras
Good point... off the top of my head I can't think of a single really good use case. Maybe Juergen knows some... in all my years of using Spring, I have never just injected a raw prototype in a raw singleton... so yeah, unless Juergen comments before this evening, I'll go add a note about that to the section that I just added. Cheers Rick Hi Rick,
I haven't seen such usage either. However, consider the example of a bean that implements a cache. Declaring one cache bean (with "prototype" scope) and injecting that dependency (using ctor/setter) into other beans will give each bean a unique, isolated cache instance. For the sake of readability I would prefer multiple (inner) cache bean declarations, but above pattern might actually be valid (but confusing). |
||||||||||||||||||||||||||||||||||||||||||||||
Cheers
Rick