Search code examples
javajakarta-eecdijava-ee-6

Overwrite CDI configuration in xml file


In jee (EJB, servlets) and many other java libraries (spring) there is a general rule that everything that is done via annotations can be overwritten with a xml file.

It seems to me that in case of CDI above rule doesn't apply. Please confirm or deny my opinion.

Does beans.xml accept only: alternatives decorators interceptors and scan top level elements (netbeans suggests only this)?

Can I for example create @Named CDI beans only via beans.xml file ?

Can I overwrite @Interceptor's @Priority in beans.xml file ?


Solution

  • Well, as I pointed out in my previous answer, you cannot overwrite interceptors in beans.xml. That's different from Spring where you can overwrite annotations by XML files or even merge them together. beans.xml is meant only for couple of following purposes (you can verify by looking at XSD schema)

    • Defining interceptor classes
    • Defining decorators
    • Registering alternatives
    • Conditional scanning

    That's currently all you can do with CDI 1.1 beans.xml.