Java Reference
In-Depth Information
Coding our EJB application
Creating EJB classes does not require getting mixed up with fancy wizards; all you need to
do is add bare Java classes. Therefore, from the File menu, go to New | Java Class , and
enter TheatreBox as the classname and
com.packtpub.wflydevelopment.chapter3.control as the package name.
We will add the following implementation to the class:
@Singleton
@Startup
@AccessTimeout(value = 5, unit = TimeUnit.MINUTES)
public class TheatreBox {
private static final Logger logger =
Logger.getLogger(TheatreBox.class);
private Map<Integer, Seat> seats;
@PostConstruct
public void setupTheatre() {
seats = new HashMap<>();
int id = 0;
for (int i = 0; i < 5; i++) {
addSeat(new Seat(++id, "Stalls", 40));
addSeat(new Seat(++id, "Circle", 20));
addSeat(new Seat(++id, "Balcony", 10));
}
logger.info("Seat Map constructed.");
}
private void addSeat(Seat seat) {
seats.put(seat.getId(), seat);
}
@Lock(READ)
public Collection<Seat> getSeats() {
return
Search WWH ::




Custom Search