© 2019

Pro CDI 2 in Java EE 8

An In-Depth Guide to Context and Dependency Injection


Table of contents

  1. Front Matter
    Pages i-xi
  2. Jan Beernink, Arjan Tijms
    Pages 1-36
  3. Jan Beernink, Arjan Tijms
    Pages 37-62
  4. Jan Beernink, Arjan Tijms
    Pages 63-96
  5. Jan Beernink, Arjan Tijms
    Pages 97-140
  6. Jan Beernink, Arjan Tijms
    Pages 141-163
  7. Jan Beernink, Arjan Tijms
    Pages 165-187
  8. Jan Beernink, Arjan Tijms
    Pages 189-212
  9. Jan Beernink, Arjan Tijms
    Pages 213-239
  10. Back Matter
    Pages 241-247

About this book


Use CDI and the new CDI 2.0 to automatically manage the lifecycle of your application’s beans using predefined scopes and define custom lifecycles using scopes. In this book, you will see how you can implement dynamic and asynchronous communication between separate beans in your application with CDI events. 

The authors explain how to add new capabilities to the CDI platform by implementing these capabilities as extensions. They show you how to use CDI in a Java SE environment with the new CDI initialization and configuration API, and how to dynamically modify the configuration of beans at application startup by using dynamic bean building.

You will:

  • Use qualifier annotations to inject specific bean implementations
  • Programmatically retrieve bean instances from the CDI container in both Java SE and Java EE when injecting them into an object isn’t possible 
  • Dynamically replace beans using the @Alternative annotation to, for example, replace a bean with a mock version for testing 
  • Work with annotation literals to get instances of annotations to use with the CDI API
  • Discover how scopes and events interact


CDI Java EE 8 Jakarta EE dependency injection DI context JavaBeans Web Beans WebBeans IoC inversion of control bean managed bean bean model Enterprise JavaBeans EJB Java Eclipse open source

Authors and affiliations

  1. 1.DublinIreland
  2. 2.AmsterdamThe Netherlands

About the authors

Jan Beernink​ works for Google and is a contributor to several projects related to OmniFaces. Jan holds an MSc degree in computer science from the Vrije Universiteit of Amsterdam, The Netherlands.

Arjan Tijms​ works for Payara Services Ltd and is a JSF (JSR 372) and Security API (JSR 375) EG member. He is the co-creator of the popular OmniFaces library for JSF that was a 2015 Duke’s Choice Award winner, and is the main creator of a set of tests for the Java EE authentication SPI (JASPIC) that has been used by various Java EE vendors. Arjan holds an MSc degree in computer science from the University of Leiden, The Netherlands.

Bibliographic information

Industry Sectors
IT & Software
Finance, Business & Banking