The Java Source

Contexts and Dependency Injection in Java EE 6

April 12, 2011 By: Janice Heiss
Java Champion, and Oracle Magazine's "Java Developer of the Year" Adam Bien, begins his precise and clear article, titled "Contexts and Dependency Injection in Java EE 6" by addressing an embarrassment of riches in Java EE 6 that leaves developers with a diverse array of choices:

"Java Platform, Enterprise Edition (Java EE) 5 brought dependency injection (DI) with Convention over Configuration to Enterprise JavaBeans (EJB) 3.0. Java EE 6 introduces the flexible and powerful @Inject dependency injection model (JSR-330 and JSR-299) in addition to the already existing @EJB annotation. So when should you use what?"

Contexts and Dependency Injection (CDI), the new Java EE 6 specification, introduces the concept of "contextual" references or scopes. Managed beans in CDI live in well-defined scope and are created and destroyed on demand by the container. Adam Bien articulates the best ways to qualify and to configure the dependencies using typed annotations, known as "qualifiers" with optional attributes instead of plain strings.

All in all, Bien gives us a detailed understanding of an important step forward in Java EE. See the story here.

Join the discussion

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha

More on Java

Integrated Cloud Applications & Platform Services