CDI events
CDI provides event-handling facilities. Events allow loosely coupled communication between different CDI beans. A CDI bean can fire an event, then one or more event listeners handle the event.
Firing CDI events
The following example is a new version of the CustomerInfoController
class we discussed in the previous section. The class has been modified to fire an event every time the user navigates to a new page:
package com.ensode.jakartaeebook.cdievents.controller; import jakarta.enterprise.context.Conversation; import jakarta.enterprise.context.RequestScoped; import jakarta.inject.Inject; import jakarta.inject.Named; import java.io.Serializable; import com.ensode.jakartaeebook.cdievents.event.NavigationInfo; import com.ensode.jakartaeebook.cdievents.model.Customer; import jakarta.enterprise.event.Event; @Named @RequestScoped public class CustomerInfoController implements Serializable { @Inject private Conversation...