© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
D. R. HeffelfingerPayara Micro Revealedhttps://doi.org/10.1007/978-1-4842-8161-1_4

4. Contexts and Dependency Injection

David R. Heffelfinger1  
(1)
Fairfax, VA, USA
 

Contexts and Dependency Injection (CDI) is a powerful dependency injection mechanism that is part of both the Jakarta EE and MicroProfile specifications. CDI allows us to easily inject dependencies into our code; it also has an event handling mechanism that allows us to loosely couple different parts of our code. In this chapter, we will see how we can incorporate CDI into our MicroProfile applications deployed to Payara Micro.

CDI Scopes

CDI beans have scopes, which denote their life cycle; a bean’s ...

Get Payara Micro Revealed: Cloud-Native Application Development with Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.