The Java Pet Store is a reference application from the Java 2 Enterprise Edition (J2EE) BluePrints program. It showcases the J2EE BluePrints application programming model and the main features of the J2EE platform.
The Java Pet Store distribution comes with full source code for the JavaServer Pages (JSP TM ), Java Servlet, and Enterprise JavaBeans (EJB TM ) components that are used to build the application. These components illustrate the typical design decisions and tradeoffs a developer makes when building an enterprise application, and as whole, they illustrate how J2EE technologies work together.
The Java Pet Store is based on the Model-View-Controller (MVC) application architecture, which separates three distinct forms of functionality within the application:
The Model represents the structure of the data in the application, as well as application-specific operation on data. The Java Pet Store model is represented by a group of classes: CartModel, InventoryModel, and others.
The View accesses data from the model and specifies how that data should be presented. Views in the Java Pet Store consist of JSP pages rendered in the browser, stand-alone applications that provide view functionality, and interfaces to spreadsheet programs, such as StarOffice.
The Controller translates user actions on the model and selects the appropriate view based on user preferences. The Controller is fronted by the MainServlet, which dispatches browser requests to other controller objects such as the ShoppingClientController, AdminClientController, and their related support classes.
The Java Pet Store is designed as a set of loosely-coupled modules, which are tightly-coupled internally. Grouping functionality into modules provides tight integration between classes that cooperate, yet decouples classes that refer to each other occasionally.
Modular design supports the design goal that software will be reusable. Each module has an interface that defines the module's functional requirements and provides a place where third-party products may be integrated.
The Java Pet Store includes modules for:
The latest release of the Java Pet Store 1.1.2 gives the developer an opportunity to take advantage of improved portability and internationalization, as well as:
Servlet-Based Sign-in/Sign-out Architecture
A new servlet-based sign-in/sign-out architecture with a handler to centralize requests replaces the previous form-based login approach, enabling the Java Pet Store to be deployed on all possible J2EE platforms without code modification.
Simplified Database Installation
A new interactive tool for installing database tables enables easier installation and faster deployment.
Exception Handling on All Tiers
The Java Pet Store has many types of built-in exceptions that components can throw, such as a FinderException for when an account or an order cannot be found, or a SigninFailedException when a customer supplies an incorrect password trying to sign in. A list of these exceptions are documented and available with the download.
All of the content presented in the Java Pet Store including the catalog data is translated into Japanese. The Java Pet Store now supports Japanese account names, searches in Japanese, and the ability to handle multiple currencies. In addition, all presentation-related code has been moved to a single utility class.
© 2001 Sun Microsystems, Inc. All rights reserved.