[cdi-dev] beans.xml quiz for Friday afternoon
Martin Kouba
mkouba at redhat.com
Fri Oct 21 09:23:27 EDT 2016
Hi all,
today I struggled with weird beans.xml parsing problems and I found out
that this part of CDI might deserve some clarification. Below are few
examples. And not all of them have obvious interpretation.
Also note that the spec still contains invalid beans.xml snippets (see
also CDI-449).
1. empty beans.xml marker file
- spec VALID, bean-discovey-mode="ALL"
- XSD validation not needed
2. <beans/>
- spec VALID, bean-discovey-mode="ALL"
- XSD validation not possible
3. <beans xmlns="http://java.sun.com/xml/ns/javaee">
- spec VALID, Java EE 6 namespace, ie. CDI 1.0, bean-discovey-mode="ALL"
- XSD validation OK (against beans_1_0.xsd)
4. <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee">
- spec VALID
- XSD validation ERROR - Java EE 7 namespace, i.e. CDI 1.1+ and
bean-discovey-mode attribute is required
- note that version is defaulted to "1.1" (and e.g. SAXParser fills this
value automatically)
- what's the correct bean-discovey-mode? => I would expect ANNOTATED
because we're in EE 7 and it's the default bean discovery mode
- bean-discovey-mode attribute is required, not defaulted
- current Weld behavior: ALL
5. <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.1">
- spec INVALID, "A bean archive which contains a beans.xml file with
version 1.1 (or later) must specify the bean-discovey-mode attribute.
The default value for the attribute is annotated."
- XSD validation ERROR, bean-discovey-mode attribute is required
- what's the correct bean-discovey-mode? => I would expect ANNOTATED
- current Weld behavior: ALL
6. <beans version="1.1">
- spec INVALID, the same as above
- XSD validation not possible
- what's the correct bean-discovey-mode? => I would expect ANNOTATED
- current Weld behavior: ALL
7. <beans version="1.1" bean-discovery-mode="annotated">
- spec VALID, bean-discovey-mode="ANNOTATED"
- XSD validation not possible
8. <beans version="1.1" bean-discovery-mode="all"
xmlns="http://xmlns.jcp.org/xml/ns/javaee">
- spec VALID, bean-discovey-mode="ALL"
- XSD VALID
We may consider adding default value for bean-discovey-mode, and maybe
rewording the spec text. But I'm no XML guru so maybe I'm missing something.
Thanks,
Martin
More information about the cdi-dev
mailing list