Java Reference
In-Depth Information
Tip
Why has this component been coded as an EJB instead of a CDI Bean?
One of the main advantages of using EJBs is that they are inherently
transac-
tional components
. If we were to use CDI Beans, we would have to manually
demarcate the transaction
begin()
and
commit()
(or
rollback()
) in every
single method.
This service is made up of four methods. The first is the
createSeatType
method,
which will be used in the first application screen to add a new
SeatType
object to
our theatre. The next method,
createTheatre
, will be invoked once we are done
with setting up our theatre; so we create the list of seats that will be available for
booking in the next screen.
Next in the list is the
bookSeat
method that, as you might have guessed, will be
used to book a seat. Finally, the
doCleanUp
is actually used to perform some clean
up if you want to restart the application.
The last piece of our puzzle is the
BookerService
class, which adds a tiny session
layer to your application.
@Named
@ConversationScoped
public class BookerService implements
Serializable {
@Inject
private Logger logger;
@Inject TicketService ticketService;
int money;
@PostConstruct