In this exercise, you will build and examine a stateful session bean, TravelAgent, which coordinates the work of booking a trip on a ship. You will also build a client application to test this EJB.
Our version of this exercise does not follow the one in the EJB section strictly. Instead of simplifying the beans and their relationships as the EJB section does, we use the beans implemented in Chapter 6 and Chapter 7 and thus take advantage of the CMP 2.0 features of JBoss.
This exercise is based on the EJBs from Exercise 7.3 and doesn’t contain much material that previous sections haven’t covered. Nevertheless, a few modifications have been made:
The Customer EJB again has a remote home and bean interfaces (as in
Chapter 6) and exposes its relationship with
the Address EJB in the remote interface through a new data object,
The Cabin EJB has a new create method that takes several parameters.
The Reservation EJB has a new create method that takes several parameters, and has a local reference to the Customer EJB.
The TravelAgent bean’s role is to perform all activities needed to book a successful trip. Thus, as in the preceding example, this session bean acts as a coordinator between different EJBs and groups several actions on different beans in the same transaction. Here, though, the bean maintains a conversational state with the client; i.e., each client has a dedicated bean on the server.
In the previous example featuring ...