The first thing we should account for is the resource injection of the Timer object  ,
which will be used in the cancelTimers method  to cancel all the scheduling
when the theatre is fully booked. Please note that the timerService.getTimers()
method retrieves all active timers associated only with the current bean. In order to get all
timers from your application module, you have to use the timerSer-
vice.getAllTimers() method, which was added recently in EJB 3.2.
Next, pay attention to the Schedule annotation  we are using, which will fire a non-
persistent timer each minute.
Persistent timers (the default option) can survive application and server crashes. When the
system recovers, any persistent timers will be recreated and missed callback events will be
When a replay of missed timer events is not desired, a non-persistent timer should be
used, as shown in the preceding example.
When an action is fired, the automaticCustomer method starts scanning the theatre
seats for an available seat. (Nothing too complex; findSeat starts looking from the first
Finally, if there are seats still available, the buyTicket method  of the
TheatreBox singleton will be used to short circuit the purchase of the seat (obviously,
we won't need to check the money for our automatic customer).
Search WWH ::