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

The following example of a schema is referenced in the beans.xml file:
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.

An explicit bean archive is an archive that contains a beans.xml file with any of the following characteristics:
  • 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.

Lorsque le schéma est mis à jour à une implémentation CDI 1.2, pour conserver l'archive de bean comme explicite, le mode de détection de bean doit être défini sur all :
<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>
Remarque : Une archive de bean implicite détecte uniquement les bean ayant une annotation de définition de bean.

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

If the following interceptor binding is declared on lifecycle interceptors, the ElementType.TYPE is only allowed Target:
@InterceptorBinding
@Retention( RetentionPolicy.RUNTIME )
@Target( {ElementType.TYPE, ElementType.METHOD} )
public @interface SFCDIInterceptorBinding {} 
 

Icône indiquant le type de rubrique Rubrique de concept



Icône d'horodatage Dernière mise à jour: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=cweb_cdi_behavior
Nom du fichier : cweb_cdi_behavior.html