Contexts and Dependency Injection

from Wikipedia, the free encyclopedia

Contexts and Dependency Injection ( CDI ) - also known as Web Beans - is a Java standard that allows the configuration of modules depending on different contexts by injecting dependencies. This external configuration of dependencies was first implemented in the Java context in the Spring framework ; the idea of ​​a holistic dependency management in the Java enterprise stack comes from the open source framework JBoss Seam ; it was formalized as JSR 299 from 2006–2009 and included in the Java Enterprise 6 standard in 2009.

CDI standardizes the principle of dependency injection for Java, according to which the dependencies used by a module are made known to the module from the outside and are only defined in the module as a dependency - interface or class, at least not a specific object instance. Depending on the context (for example in a standalone application or as an enterprise bean in an application server , but also in the module test or integration test ), these dependencies can be set differently.

The CDI specification provides for extensive modularization through the definition of life cycles (state transition models) for Java objects, the integration with JavaServer Pages and JavaServer Faces via Expression Language , the decoration and interception of objects and an event notification model in front. A corresponding service interface (SPI) can be used to expand CDI on a modular basis.

Individual evidence

  1. Java Community Process (2009): JSR 299: Contexts and Dependency Injection for the Java EE platform. Retrieved October 19, 2012.