Introducing the DayTrader Application
DayTrader is a real world application developed by IBM and then donated to the Apache Geronimo project. Its goal is to serve as both a functional example of a full-stack J2EE 1.4 application and as a test bed for running performance tests. This chapter demonstrates how to use Maven on a real application to show how to address the complex issues related to automated builds. Through this example, you’ll learn how to build EARs, EJBs, Web services, and Web applications. As importantly, you’ll learn how to automate configuration and deployment of J2EE application servers.
The functional goal of the DayTrader application is to buy and sell stock, and its architecture is shown in Figure 4-1.
Figure 4-1: Architecture of the DayTrader application
There are 4 layers in the architecture:
- The Client layer offers 3 ways to access the application: using a browser, using Web services, and using the Quote Streamer.
- The Quote Streamer is a Swing GUI application that monitors quote information about stocks in real-time as the price changes.
- The Web layer offers a view of the application for both the Web client and the Web services client. It uses servlets and JSPs.
- The EJB layer is where the business logic is. The Trade Session is a stateless session bean that offers the business services such as login, logout, get a stock quote, buy or sell a stock, cancel an order, and so on. It uses container-managed persistence (CMP) entity beans for storing the business objects (Order, Account, Holding,Quote and AccountProfile), and Message-Driven Beans (MDB) to send purchase orders and get quote changes.
- The Data layer consists of a database used for storing the business objects and the status of each purchase, and a JMS Server for interacting with the outside world.
A typical “buy stock” use case consists of the following steps that were shown in Figure 4-1:
- The user gives a buy order (by using the Web client or the Web services client). This request is handled by the Trade Session bean.
- A new “open” order is saved in the database using the CMP Entity Beans.
- The order is then queued for processing in the JMS Message Server.
- The creation of the “open” order is confirmed for the user.
- Asynchronously the order that was placed on the queue is processed and the purchase completed. Once this happens, the Trade Broker MDB is notified.
- The Trade Broker calls the Trade Session bean which in turn calls the CMP entity beans to mark the order as “completed”. The user is notified of the completed order on a subsequent request.