Contexts and Dependency Injection (CDI)

Learn about Contexts and Dependency Injection 1.2 for the Java™ EE platform (CDI 1.2), which is a JSR 346 implementation that is based on JBoss Weld.

CDI is activated in an application either by the presence of a beans.xml file inside that module, or by bean defining annotations that are defined in the JSR 346 specification. You can find the beans.xml file in the WEB-INF directory of a web archive (WAR), or META-INF directory of other types of archives. Lorsque CDI est activée, le conteneur fournit des services tels que :
  • La gestion des contextes.
  • L'injection de dépendances garantissant la cohérence des types : un bean géré par CDI est instancié et injecté selon nécessité.
  • Des décorateurs, qui implémentent une ou plusieurs interfaces de bean et peuvent contenir de la logique métier. Les décorateurs sont désactivés par défaut. You can have multiple decorators per bean and order is defined by the beans.xml file. Use beans.xml or @Priority to enable the decorators.
  • Interceptor bindings: Interceptors, which are enabled manually in the beans.xml file or enabled globally with @Priority, are bound by using an interceptor binding type.
  • Un modèle d'événement.
  • Integration into JavaServer Faces (JSF) and JavaServer Pages (JSP) files that use the Expression Language (EL)
  • JavaEE component classes that support injections and the use of interceptors

Les classes de l'API officielle, telles que spécifiées par JSR 299 et JSR 330, ainsi que les classes de l'implémentation modifiée par IBM® (et qui s'appuient sur le projet Apache OpenWebBeans) sont livrées avec l'environnement d'exécution du serveur d'applications.

Although the product CDI implementation is based on Apache OpenWebBeans, the following changes and additions are added to OpenWebBeans to support integration with the server run time:
  • Integration with other Java Platform, Enterprise Edition (Java EE) containers in WebSphere Application Server Traditional that support injectable components.
  • ScannerService implementation that uses the WebSphere Application Server Traditional byte code scanner.
  • Direct use of product Enterprise JavaBeans (EJB) metadata for determining EJB types.
  • Automatic registration of Servlet Listeners, Filters, Interceptors for CDI applications that no longer need to be added by each application.
  • Product-specific implementations of many OpenWebBeans Service Programming Interfaces (SPI), such as ResourceInjectionService, TransactionService, and failover service.
Important : Les transactions et la sécurité gérées par le conteneur ne sont pas fournis par CDI.
Eviter les incidents Eviter les incidents: CDI is only supported by the default WebSphere Application Server Traditional class loader policy, Class loader for each WAR file in application, and not with the alternative, single class loader for application setting.gotcha

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
Nom du fichier : cweb_cdi.html