Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CDI discovery-mode annotated doesn't scan stereotypes bean

Why bean-discovery-mode="annotated" doesn't scan beans annotated with some stereotype, such as @Model - I just tried that and classes annotated this way weren't pick up by CDI so I had to change the mode back to the all. So is this a bug (because for instance @Model has a scope) or is this by design?

like image 596
Petr Mensik Avatar asked Feb 16 '26 10:02

Petr Mensik


1 Answers

With the bean-discovery-mode="annotated" in CDI 1.1, only beans annotated with a bean defining annotation are picked up by CDI as beans. This is described in the CDI 1.1 specification, chapter 2.5. As can be seen there, stereotypes are not included in the set of bean-defining annotations. Only scope types are bean-defining.

The @Model annotation is a built-in CDI stereotype. Therefore in CDI 1.1, annotating a bean @Model is not enough to get it discovered in the annotated discovery mode.

This is, however, going to change with CDI 1.2 (chapter 2.5.1), where stereotypes are considered bean-defining annotations.

like image 138
rsmeral Avatar answered Feb 19 '26 00:02

rsmeral



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!