© Jan Beernink and Arjan Tijms 2019
J. Beernink, A. TijmsPro CDI 2 in Java EE 8https://doi.org/10.1007/978-1-4842-4363-3_4

4. Scopes and Contexts

Jan Beernink1  and Arjan Tijms2
(1)
Dublin, Ireland
(2)
Amsterdam, Noord-Holland, The Netherlands
 

Because the CDI container is responsible for the creation and destruction of beans in a CDI-enabled application, it essentially is responsible for the lifecycle of the beans it manages. This means the container should be made aware when it is safe to create and destroy each bean. If a bean is created too late, code depending on that bean may fail. If the bean is destroyed too late, memory may become clogged up with old, obsolete objects, leading to longer garbage collection pauses and eventually out-of-memory ...

Get Pro CDI 2 in Java EE 8: An In-Depth Guide to Context and Dependency Injection 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.