Java Reference
In-Depth Information
Adding services to your application
Until now, we coded all the information that will be visible to the user through the applica-
tion screen. What is obviously missing here is all the business logic that translates ulti-
mately into inserting data or updating the existing data. For this reason, we will now add
two classes; first, under com.packtpub.wflydevelopment.chapter5.control
package and second under
com.packtpub.wflydevelopment.chapter5.controller . The first one is
TicketService , which is a stateless EJB that will be used to perform the core business
logic of this application, and the second one is our stateful EJB's counterpart, the
BookerService class. Let's start with the stateless EJB:
@Stateless
public class TicketService {
@Inject
private Logger log;
@Inject
private Event<SeatType> seatTypeEventSrc;
@Inject
private Event<Seat> seatEventSrc;
@Inject
private SeatDao seatDao;
@Inject
private SeatTypeDao seatTypeDao;
public void createSeatType(SeatType seatType) throws
Exception {
log.info("Registering " + seatType.getDescription());
seatTypeDao.persist(seatType);
seatTypeEventSrc.fire(seatType);
}
public void createTheatre(List<SeatType> seatTypes) {
Search WWH ::




Custom Search