Case Study Example: The Pet Store


The case study application is an online pet store. In this example, we have a catalog system stored in a database that is accessed by a Web application. This example can display the catalog to customers and also has a small content-management system that enables the owner of the pet store to enter catalog information (for example, new pets and new categories of pets). You can download the complete code from www.wrox.com.

The case study application is a more complex ”but more realistic ”example for demonstrating how open source tools are used in a real production environment. Even so, this example is by no means a complete pet store like the J2EE Blueprint Pet Store. Sun s purpose for building the J2EE Blueprint Pet Store is to show good design and coding techniques for building an e-commerce application with J2EE. Conversely, our pet store case study is built to demonstrate good techniques for testing, building, and deploying a J2EE application with open source tools.

We ll work through several iterations of the pet store. The baseline version has no connection pooling and no EJBs. This iteration is a simple, small example. It has several JSPs, a few classes that use JDBC, and some tables in a database. We discuss the details of the baseline version in subsequent sections of this chapter.

The second iteration of the case study changes the content management piece of the system to a container managed persistence (CMP) entity bean, which implements the backend product management. This approach allows online product entry (add, delete, and edit). This iteration demonstrates how to incorporate enterprise bean deployment into your Web application and how to ensure that the unit testing of the category systems still works after the addition of the CMP entity bean support.

The third iteration of the case study uses an EJB stateless session bean to add pooling of connections and prepared statements. We use this iteration to demonstrate the use of JUnitPerf and show the time savings from pooling prepared statements when the site is hit by many users (the original, non-pooled version would most likely be a bottleneck under heavy traffic).

The fourth iteration of the case study creates a Catalog TagLib. We use Cactus to test this TagLib. This is an excellent example to show how to operate and run Cactus tests and how to integrate them in the build/deploy process.

start sidebar
Database

The example applications in this book use MS SQL Server, primarily because it is what a large number of developers use. Realizing the irony of writing a book about open source tools, yet using a closed source database, we ported several of the example applications to HSQL (a very fast, light-weight, open source database written in Java). These example applications are available on the book s Web site at: www.wrox.com.

end sidebar
 

The fifth iteration of the case study refactors the JSPs using the Apache Struts project. Then, it uses HttpUnit to test that the application still works. The HttpUnit test is run against the baseline and the new version to show that the new version works like the old.

The sixth and final iteration of the case study refactors the Web application to use Extensible Style Language Transformation (XSLT) instead of JSP to do the catalog view. It then compares the throughput of the two approaches using JMeter.




Professional Java Tools for Extreme Programming
Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)
ISBN: 0764556177
EAN: 2147483647
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net