[cdi-dev] explicit bean archives discovery-mode 'annotated'

Mark Struberg struberg at yahoo.de
Wed Mar 4 14:25:44 EST 2015


Hi!

I think I’ve implemented the behavour the spec defines - but it does not make much sense.

First let’s look at the spec:

11.5.6. ProcessAnnotatedType event
The container must fire an event, before it processes a type, for every Java class, interface
(excluding the special kind of interface declaration annotation type) or enum DISCOVERED
as defined in Section 12.4.1, “Type discovery”

12.4.1 defines…
First the container must discover types. The container discovers:
• each Java class with a bean defining annotation in an implicit bean archive.


And in 2.5 we can read
"f the bean discovery mode is annotated then:
• bean classes that don’t have bean defining annotation (as defined in Section 2.5.1, “Bean defining annotations”) and are not bean classes of sessions beans, are NOT DISCOVERED“



Which to me means that for a BDA with discovery-mode = „annotated“ we ONLY must fire ProcessAnnotatedType for classes with bean defining annotations, and NOT for interfaces or enums.
If this is true, then it is a huge mess for lots of CDI Extensions. It basically renders the ‚annotated‘ mode pretty much useless.


What we really need instead is a mode which will not automatically make a @Dependent bean out of every class later. But I really would ‚discover‘ all classes in a BDA and pass them to ProcessAnnotatedType.
Some way to fix this or do we have to wait for CDI-2.0 to repair CDI-1.1?

LieGrue,
strub




More information about the cdi-dev mailing list