Rechercher un schéma valide dans beans.xml

Si un fichier beans.xml inclut des décorateurs ou des intercepteurs, un schéma valide doit être utilisé pour une instanciation correcte. L'espace de nom et l'emplacement du schéma dans le fichier beans.xml doivent se conformer à la spécification pour la version CDI applicable.

Cette règle analyse les fichiers beans.xml pour voir si l'espace de noms fourni dans l'espace de noms xmlns correspond à l'emplacement de schéma correspondant sur le schemaLocation Attribut.

L'exemple suivant illustre un fichier beans.xml valide pour la spécification CDI 1.0.


<beans xmlns="http://java.sun.com/xml/ns/javaee" 
		  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
		  		      		 http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans> 

L'exemple suivant illustre un fichier beans.xml valide pour la spécification CDI 1.2.


<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
		  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
		  		      		 http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" 
		  				 			 bean-discovery-mode="all" version="1.1">
</beans>
 

Si aucun espace de nom n'est fourni, la règle ne marque pas le fichier beans.xml.

Le correctif automatique de cette règle met à jour les espaces de noms incompatibles avec la valeur appropriée à l'espace de noms spécifié schemaLocation. Copiez la configuration personnalisée vers votre fichier de génération d'application pour activer l'automatisation des correctifs.

Si vous envisagez d'utiliser la fonction CDI 1.2 fournie avec Java EE 7, voir Changements de comportement dans Contexts and Dependency Injection 1.2.