Implementing observers
When an event is launched by a launcher, some elements will react to this event and process a task with the data given on an event. These elements are called observers and work as observer patterns, which create a one-to-many relationship between objects.
This occurs when one object is the subject and the other objects are the observers. Then, when the subject object is updated, all observer objects that are related to this subject-object are updated too.
CDI has a mechanism for creating observers that will react with its events. In our example, we will launch an event, create observers to react to these events, and process a task. To do this, we will create handlers that represent our observer and process tasks. These ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access