Changements de comportement dans Contexts and Dependency Injection 1.2
L'implémentation Contexts and Dependency Injection (CDI) 1.2 contient des changements de comportement qui peuvent provoquer qu'une application ayant migré depuis CDI 1.0 se comporte différemment ou échoue sous CDI 1.2.
While CDI 1.0 is built on the Apache OpenWebBeans implementation of CDI, CDI 1.2 is built on the Weld implementation. The behavior changes introduced reflect the differences in the two implementations.
CID de l'ID de conversation
Dans l'implémentation CDI 1.0, le CID est unique au niveau global. Dans CDI 1.2, il est unique par session HTTP. This behavior is in line with the CDI specification and is implemented by the Weld. Pour obtenir un CID unique à niveau global, le CID doit être spécifié au début de la conversation en appelant Conversation.begin.
Référencement des schémas dans le fichier beans.xml
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"
Si
vous utilisez un schéma non valide, le serveur produit une erreur
d'exception. Set the
org.jboss.weld.xml.disableValidating=true to turn off the validation of the
beans.xml file and prevent the error. Si le fichier
beans.xml spécifie des décorateurs ou des
intercepteurs, un schéma valide doit être utilisé, sinon les
décorateurs et les intercepteurs ne sont pas instanciés
correctement.Archives de bean implicites
The CDI 1.2 implementation defines two different types of bean archives, explicit and implicit.
- A version number of 1.1 (or later), and with the bean-discovery-mode of all
- No version number
- An empty file
Une archive de bean implicite est tout autre archive contenant une ou plusieurs classes de bean avec une annotation de définition de bean (comme défini dans la section 2.5.1 "Bean defining annotations" de la spécification) ou un ou plusieurs bean de session. Voir la spécification : Contexts and Dependency Injection for the Java™ EE platform.
<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>
This new type of bean archive can result in an archive that is not intended to be a CDI bean archive, but it becomes an implicit bean archive in the CDI 1.2 implementation. To stop this behavior, you can add a beans.xml file with the bean discovery mode set to none to prevent the archive from being a bean archive. As an alternative solution, set the system property, com.ibm.ws.cdi.enableImplicitBeanArchives, to false. Setting this property to false prevents the archives without beans.xml files from becoming implicit bean archives and reduces startup time. To learn how to set the system property, see Java virtual machine settings.
Lifecycle interceptors
@InterceptorBinding
@Retention( RetentionPolicy.RUNTIME )
@Target( {ElementType.TYPE, ElementType.METHOD} )
public @interface SFCDIInterceptorBinding {}