Java Reference
In-Depth Information
Finally, notice that we can safely inject EJBs into our CDI Beans using the Inject [4]
annotation. Also, the reverse is perfectly legal, that is, injecting CDI Beans into EJBs.
Compared to our earlier project, here we don't raise Java exceptions when the customer is
not able to afford a ticket. Since the application is web based, we simply display a warn-
ing message to the client using JSF Faces Messages [6] .
The other bean that we still use in our application is TheatreInfo , which has been
moved to the controller package as it will actually provide the application with the
list of available seats:
package com.packtpub.wflydevelopment.chapter4.controller;
import com.google.common.collect.Lists;
import
com.packtpub.wflydevelopment.chapter4.boundary.TheatreBox;
import com.packtpub.wflydevelopment.chapter4.entity.Seat;
import javax.annotation.PostConstruct;
import javax.enterprise.event.Observes;
import javax.enterprise.event.Reception;
import javax.enterprise.inject.Model;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Collection;
@Model [1]
public class TheatreInfo {
@Inject
private TheatreBox box;
private Collection<Seat> seats;
@PostConstruct
public void retrieveAllSeatsOrderedByName() {
seats = box.getSeats();
}
Search WWH ::




Custom Search