Section 6.5. Our Example

6.5. Our Example

We are going to upgrade the JAW Motors application by adding a "Buy Car" user story that uses a transaction. In addition to marking a record into the CAR table as "Sold", we'll also insert a corresponding record into the ACCOUNTING table. A Session Bean is appropriate because buying a car is an atomic transaction. The update to the CAR table and the insert into the ACCOUNTING table must both succeedif one database operation fails, the other operation rolls back. We'll take three iterations to move from a web-only application to one that uses a Session Bean for its business logic:

Iteration 1

Introduce a Session Bean. The Controller Servlet uses the InventoryFacadeBean rather than the DAO to list the cars on the web page. All other actions in the Controller Servlet still use the DAO.

Iteration 2

We then move all business logic out of the Controller Servlet into the InventoryFacadeBean (which wraps the DAO).

Iteration 3

Upgrade the web pages, Controller Servlet, and InventoryFacadeBean to buy a car. We'll also create a new AccountingHibernateDAO and AccountingDTO for the ACCOUNTING table.

JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: