20
Java Petstore : A Case Study Rohit Nambiar July 2005

Java Petstore : A Case Study Rohit Nambiar July 2005

Embed Size (px)

Citation preview

Java Petstore : A Case Study

Rohit Nambiar

July 2005

OBJECTIVE :

Demonstrate, Java BluePrints help in building flexible, scalable, cross-platform Web-based applications.

Show the recommended Architectural design pattern approaches to designing J2ee application.

Discuss the Architecture of the Petstore Application.

Discuss the consistent Petstore design conforming to the J2ee Design Patterns.

Give an Overview as to how the application benefits from such Architecture and Design.

Build and run the petstore application.

Unit testing, Profiling and Load testing the Petstore application to get some performance statistics.

Background : Basic J2ee Architecture

Background continued……

J2EE application is hosted within a container

Consists of Client Tier, Web Service container and Back end Database

Web Service container – Web Container and EJB container

Business logic is built using Enterprise JavaBeans (EJB) components. and connects to databases using JDBC or SQL/J

Business partners can connect with J2EE applications through web services technologies (SOAP, UDDI, WSDL, ebXML)

Introduction Continued…… Use Case Diagram

Customer

sign off

search catalog

Browse item

Browse Product

Browse Categories

Update ShoppingCart

Update Personalinfo

Update Account

Submit Order Send Purchase Order

Browse cataloug

*

*

*

**

*

*

*

*

*

*

*

ACTOR ACTION DESCRIPTION

Customer Homepage The main page that loads when the user first starts the application.

Customer Browse catalog Each category has several products associated to it

Customer Browse Detail Each product variant has detailed view that displays the product description, a product image, price, and the quantity in stock.

Customer Browse Item Each Item is viewed.

Customer Browse Products If we now select a product the application will display all variants of the product.

Customer Update Cart This allows the user to manipulate the shopping cart (add, remove, and update line items).

Customer Update Personal Info This allows user to update and manage his personal information

Customer Update Account This allows user to view his Account.

Customer Sign Off The checkout page displays the shopping cart.

Customer Submit Order The billing and the shipping addresses are displayed.

Customer Purchase Order The final step wherein the order is committed to the database.

Petstore Model View Controller Architecture:

Filter Request

Extract Data

Map Request To Command

Invoke Command To Request

Browser Client

Format Page To Display

Determine Page To Display

Organize Work For Request

Retrieve Data Perform operation

MODEL

CONTROLLER

VIEW

The MVC architecture provides flexibility, reusability, testability and clear design roles for application components.

Structural View Architecture:

Petstore Modules & Functionalities:

MODULES FUNCTIONALITY

SignOn It helps a user to sign on before accessing certain screens, and manages the sign on process

Control Sends request to the business logic, controls screen flow, also coordinates component interactions.

Product Catalog User can search for products and also shows the descriptions of the selected items

Customer This module helps in representing customer information like address, credit card info and contact info.

Mail Used for sending confirmation messages to the user.

Shopping Cart It tracks the items a user has selected for purchase.

Web Application Framework

Class Diagram – SignOn Module

+processRequest()

RequestProcessor

+perfom()

«interface»HTMLAction

+perform()

CreateUserHTMLAction

+handleEvent()

«interface»ShoppingWebController

+handleEvent()

«interface»WebController

+getEventName()

«interface»Event

+processEvent()

EJBController

SHoppingController EJB

+getEventName()

CreateUserEvent SignOn

UserEJB

CreateUserEJBAction

+performs()

«interface»EJBAction

Product Catalog Module

Shopping Cart Module

Client

+addItem()+setLocale()+getItem()+deleteItem()+UpdateItemquantity()+getsubTotal()+getCount()+empty()

ShoppingCartLocal

+create()

ShoppingCartLocalHome

+addItem()+setLocale()+getItems()+deleteItems()+UpdateItemQuantity()+getSubTotal()+getCount()+empty()

ShoppingCartEJB

+category()+itemid()+productid()+name()+attribute()+quantity()+unitcost()+totalcost()

CartItem

Mail Module:EJBAction

EJBActionSupport

OrderEJBAction

+getQueueConnectionFactory()+getQueue()+getLocalHome()

ServiceLocator

UniqueIdGeneratorEJB

PurchaseOrder

+sendMessage()

AsyncSenderEJB

+OnMessage()

PurchaseOrderMDB

PurchaseOrder

Customer Module:

Control Module:

Filter Request: Encoding Filter, which ensures that request and response encoding match and SignOnFilter, which enforces security and performs user signon.

Front Controller - MainServlet processes all requests and handles request dispatch, screen flow, and view generation.

Map request to HTML action and execute HTML action

Map event to EJB action and execute EJB action

View selection

Control Module Continued……..

PAGE FLOW DIAGRAM:

Evaluations:

Web Application Framework - WAF provides a number of services including request filtering and dispatching, templated view generation, a set of reusable custom tags, and screen flow control.

EJB centric design – For Petstore, the buisness logic is shifted to the EJB tier. This provides scalability, reliability, persistence, asynchronous communication and security control.

Local enterprise beans – It provides high-performance access to fine-grained business logic, while maintaining the high-level services of an enterprise beans container.

Code Complexity – Approximately 14200 lines of code. 100 Packages appx and 300 Classes appx.

Enhancement:

Sun claims blueprints described are not for performance but is a kind of benchmark for building j2ee applications.

No real performance measure were done to compare with other web applications.

To have a comparative case study of the architectural and design differences of a java Petstore and an equivalent .Net Petshop and run some perfomance tests to get some statistics.

Refrences:

[1] Sun Microsystems, 1994-2005; www.java.sun.com[2] Java Blueprints, http://java.sun.com/reference/blueprints[3] Java Petstore Source code, http://java.sun.com/j2ee//1.4/download.html#samples[4] D. Alur, J. Crupi, D. Malks. Core J2EE Patterns., Prentice Hall PTR.[5] Model–View–Controller, http://java.sun.com/blueprints/patterns/j2ee_patterns/model_view_controller/ [6] Core j2ee Patterns, http://java.sun.com/blueprints/corej2eepatterns/index.html[7] Designing Enterprise Applications with the J2EETM Platform, Second Edition http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/ [8] Java Pet Store Sample Application Implements Core J2EE Patterns, http://java.sun.com/blueprints/patterns/catalog.html [9] AppPerfect DevSuite 5.0 Testing Tool, http://www.appperfect.com/products/devsuite/index.html