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.
CDI events
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 net.ensode.javaee8book.cdievents.controller;
import java.io.Serializable;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;
import net.ensode.javaee8book.cdievents...