Reputation: 1067
The instances passed to my producer does represent effective beans?
@Qualif1
@Prodcues
B qualif1(@Any Instance<B> instances){
return instances.select(B1.class).get(); // Select instance of B1 which extends B
}
I am wondering if instances are already beans or only the selected one will be a bean managed by the container?
Thanks in advance
Upvotes: 0
Views: 55
Reputation: 12495
This does not depend on using instances
, but on the scopes of the beans. A call to get
works like any other injection point: if you get
a prototype bean, a new instance of the bean gets created. If you get
an eager singleton - it is already created before you call get
.
It seems like your question stems from mixing up beans and instances of beans: the former are definitions (and are all, in a sense "managed" by the container), the latter are instances (which are in the direct sense "managed").
The ladder of abstraction goes like this:
class -> bean -> instance
So the "bean" is neither a class (although in some projects every bean is also a class) nor an instance (although in some projects every bean is also an instance).
Personally, I blame Spring for blurring the boundaries between the three, by encouraging usage of eager singletons for practically everything.
Upvotes: 1