The Java EE 5 Tutorial

Overview of the Coffee Break Application

The Coffee Break does not maintain any inventory. It handles customer and order management and billing. Each order is filled by forwarding suborders to one or more coffee suppliers. Figure 36–1 shows this process.

Figure 36–1 Coffee Break Application Flow

A diagram showing the interaction of the Coffee Break
client, server, and web services

The Coffee Break server obtains the coffee varieties and their prices by querying suppliers at startup and on demand.

  1. The Coffee Break server uses SAAJ messaging to communicate with one of the suppliers. The Coffee Break has been dealing with this supplier for some time and has previously made the necessary arrangements for doing request-response SAAJ messaging. The two parties have agreed to exchange four kinds of XML messages and have set up the DTDs those messages will follow.

  2. The Coffee Break server requests price lists from each of the coffee suppliers. The server makes the appropriate remote web service calls and waits for the response, which is a JavaBeans component representing a price list. The SAAJ supplier returns price lists as XML documents.

  3. Upon receiving the responses, the Coffee Break server processes the price lists from the JavaBeans components returned by calls to the suppliers.

  4. The Coffee Break server creates a local database of suppliers.

  5. When an order is placed, suborders are sent to one or more suppliers using the supplier’s preferred protocol.