2002 Prentice Hall. All rights reserved. Chapter 17: Enterprise Java Case Study: Architectural Overview Outline 17.1 Introduction 17.2 Deitel Bookstore 17.3 System Architecture 17.4 Enterprise JavaBeans Entity EJBs Stateful Session EJBs 17.5 Servlet Controller Logic 17.6 XSLT Presentation Logic
2002 Prentice Hall. All rights reserved Introduction Online bookstore e-business application –Servlets –EJBs –XML –XSLT –MVC architecture
2002 Prentice Hall. All rights reserved Deitel Bookstore Case study –Implement functionality for commercial on-line store Provide product catalog Provide shopping cart Provide customer registration Allow customers to view previous orders Provide functionality for several clients –Standard Web browsers –WML browsers –cHTML browsers
2002 Prentice Hall. All rights reserved System Architecture Multi-tier application –Information tier Maintains data for application (RDBMS) –Middle tier Implements business logic and controller logic –Control interactions between information and client tiers –Client tier Application’s user interface (e.g., Web browser)
2002 Prentice Hall. All rights reserved System Architecture (cont.) Fig. 17.1Three-tier application model in Deitel Bookstore.
2002 Prentice Hall. All rights reserved System Architecture (cont.) Fig. 17.2Detailed architecture of Deitel Bookstore Enterprise Java case study.
2002 Prentice Hall. All rights reserved Enterprise JavaBeans EJBs –Implement business logic and database abstraction layer –Stateful session EJB Represents a customer’s shopping cart –Entity EJB Provide object-based interface to information tier Servlets –Use EJB business logic to create an on-line store
2002 Prentice Hall. All rights reserved Entity EJBs Entity EJB –Provide object-based interface to information tier –Represents object stored in application’s relational database Class Customer stores –First name –Last name –Billing address –Shipping address –Credit-card information Class Product
2002 Prentice Hall. All rights reserved Entity EJBs (cont.) Entity EJB –Each entity EJB has corresponding model class Has properties for each entity EJB property e.g., Product EJB has corresponding ProductModel –ProductModel has properties for Product ISBN Product price Product author
2002 Prentice Hall. All rights reserved Stateful Session EJBs ShoppingCart –Stateful session EJB –Manages customer’s shopping cart –Primary business-logic component in Deitel Bookstore
2002 Prentice Hall. All rights reserved Servlet Controller Logic Servlets –Middle-tier interface between client and business logic –Implement the controller in MVC architecture –Interact with EJB business-logic components Handle client requests (via HTTP and WAP) Process data as XML documents Pass XML documents through XSL transformations –Produce presentation for each client
2002 Prentice Hall. All rights reserved XSLT Presentation Logic Generate appropriate presentation for each client –Each servlet employs XSL Transformer and XSLTs One XLST for producing XHTML One XLST for producing WML One XLST for producing cHTML
2002 Prentice Hall. All rights reserved. Outline Fig XML file generated by Get- ProductServlet. Lines Prentice Hall 6 Deitel, Deitel, Nieto, Lin & Sadhu 7 XML How to Program 8 $ images/xmlhtp1.jpg 11 CD XML document marks up a product, including the product’s ISBN, title, author, publisher and price
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating XHTML from GetProduct- Servlet (part 1). Lines <xsl:stylesheet version = "1.0" 8 xmlns:xsl = " <xsl:output method = "xml" omit-xml-declaration = "no" 11 indent = "yes" doctype-system = "DTD/xhtml1-strict.dtd" 12 doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"/> <html xmlns = " 20 xml:lang = "en" lang = "en"> Description <xsl:for-each select = 34 "document( '/XSLT/XHTML/navigation.xml' )"> 35 Extract relevant pieces of information from the XML document to create appropriate XHTML representation
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating XHTML from GetProduct- Servlet (part 2) by <img class = "bookCover" 52 src = "images/{image}" 53 alt = "{title} cover image."/> Price: ISBN: Pages: 67 68
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating XHTML from GetProduct- Servlet (part 3) Publisher: <input type = "submit" 78 value = "Add to cart"/> <input type = "hidden" name = "ISBN" 81 value = "{ISBN}"/>
2002 Prentice Hall. All rights reserved. Outline Fig XHTML document generated by XSLT in Get- ProductServlet (part 1). 1 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 "DTD/xhtml1-strict.dtd"> 4 <html xmlns=" 5 lang="en" xml:lang="en"> 6 7 XML How to Program -- Description <img src="images/logotiny.gif" 17 alt="Deitel & Associates, Inc. logo." /> <div style= 22 "position: relative; bottom: -50px;"> <input type="text" size="15" 25 name="searchString" />
2002 Prentice Hall. All rights reserved. Outline Fig XHTML document generated by XSLT in Get- ProductServlet (part 2) Product Catalog Create Account Log in Shopping Cart Order History XML How to Program by Deitel, Deitel, Nieto, Lin & Sadhu
2002 Prentice Hall. All rights reserved. Outline Fig XHTML document generated by XSLT in Get- ProductServlet (part 3). 69 <img alt="XML How to Program cover image." 70 src="images/xmlhtp1.jpg" 71 class="bookCover" /> Price: $ ISBN: Pages: Publisher: Prentice Hall <input value="Add to cart" 85 type="submit" /> 86 <input value=" " 87 name="ISBN" type="hidden" />
2002 Prentice Hall. All rights reserved. Outline Fig XHTML document generated by XSLT in Get- ProductServlet (part 4).
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating WML from GetProduct- Servlet (part 1). Lines <xsl:stylesheet version = "1.0" 4 xmlns:xsl = " 5 6 <xsl:output method = "xml" omit-xml-declaration = "no" 7 doctype-system = " 8 doctype-public = "-//WAPFORUM//DTD WML 1.1//EN"/> Description: by ISBN: Extract relevant pieces of information from the XML document to create appropriate WML representation
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating WML from GetProduct- Servlet (part 2). 36 Price: 37 $ Publisher: Pages:
2002 Prentice Hall. All rights reserved. Outline Fig WML document generated by XSLT in Get- ProductServlet (part 1). Lines <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 3 " Description: 14 XML How to Program 15 by Deitel, Deitel, Nieto, Lin & Sadhu ISBN: Price: $$ Publisher: Prentice Hall 24 Pages: WML document contains little formatting information, because display capabilities are limited
2002 Prentice Hall. All rights reserved. Outline Fig WML document generated by XSLT in Get- ProductServlet (part 2).
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating cHTML from GetProduct- Servlet (part 1). Lines <xsl:stylesheet version = "1.0" 4 xmlns:xsl = " 5 6 <xsl:output method = "html" 7 omit-xml-declaration = "yes" 8 indent = "yes" 9 doctype-system = 10 " 11 doctype-public = "-//W3C//DTD HTML 2.0//EN"/> Description by Extract relevant pieces of information from the XML document to create appropriate cHTML representation
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating cHTML from GetProduct- Servlet (part 2) <img class = "bookCover" 39 src = "images/{image}"/> Price: ISBN: Pages: Publisher: <input type = "submit" 64 value = "Add to cart"/> 65 66
2002 Prentice Hall. All rights reserved. Outline Fig XSL transformation for generating cHTML from GetProduct- Servlet (part 3). 67 <input type = "hidden" name = "ISBN" 68 value = "{ISBN}"/>
2002 Prentice Hall. All rights reserved. Outline Fig cHTML document generated by XSLT in Get- ProductServlet (part 1). 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 2.0//EN" 2 " <META http-equiv="Content-Type" 6 content="text/html; charset=UTF-8"> 7 XML How to Program -- Description XML How to Program by Deitel, Deitel, Nieto, Lin & Sadhu Price: $ ISBN: Pages: Publisher: Prentice Hall <input value=" " name="ISBN" 34 type="hidden"> 35
2002 Prentice Hall. All rights reserved. Outline Fig cHTML document generated by XSLT in Get- ProductServlet (part 2)