© 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_5

5. Events

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

The observer pattern is a common design pattern used in many applications. It allows an object to notify any number of other objects of changes or other events, without a strong coupling between the subject and the observer. Consider the alternative, where the observee needs to individually call each observer separately. This does not scale well to a large number of observers and strongly couples the subject that is being observed to the observers.

CDI supports the observer pattern through events. Events can be fired from any ...

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.