1 / 29

Chapter 17: Enterprise Java Case Study: Architectural Overview

Chapter 17: Enterprise Java Case Study: Architectural Overview. Outline 17.1 Introduction 17.2 Deitel Bookstore 17.3 System Architecture 17.4 Enterprise JavaBeans 17.4.1 Entity EJBs 17.4.2 Stateful Session EJBs 17.5 Servlet Controller Logic 17.6 XSLT Presentation Logic.

dory
Télécharger la présentation

Chapter 17: Enterprise Java Case Study: Architectural Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 17: Enterprise Java Case Study: Architectural Overview Outline17.1 Introduction17.2 Deitel Bookstore17.3 System Architecture17.4 Enterprise JavaBeans 17.4.1 Entity EJBs 17.4.2 Stateful Session EJBs17.5 Servlet Controller Logic17.6 XSLT Presentation Logic

  2. 17.1 Introduction • Online bookstore e-business application • Servlets • EJBs • XML • XSLT • MVC architecture

  3. 17.2 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

  4. 17.3 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)

  5. 17.3 System Architecture (cont.) Fig. 17.1 Three-tier application model in Deitel Bookstore.

  6. 17.3 System Architecture (cont.) Fig. 17.2 Detailed architecture of Deitel Bookstore Enterprise Java case study.

  7. 17.4 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

  8. 17.4.1 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

  9. 17.4.1 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

  10. 17.4.2 Stateful Session EJBs • ShoppingCart • Stateful session EJB • Manages customer’s shopping cart • Primary business-logic component in Deitel Bookstore

  11. 17.5 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

  12. 17.6 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

  13. XML document marks up a product, including the product’s ISBN, title, author, publisher and price 1 <?xml version="1.0"encoding="UTF-8"?> 2 <catalog> 3 <product> 4 <isbn>0130284173</isbn> 5 <publisher>Prentice Hall</publisher> 6 <author>Deitel, Deitel, Nieto, Lin &amp; Sadhu</author> 7 <title>XML How to Program</title> 8 <price>$69.95</price> 9 <pages>1200</pages> 10 <image>images/xmlhtp1.jpg</image> 11 <media>CD</media> 12 <quantity>500</quantity> 13 </product> 14 </catalog> Fig. 17.3 XML file generated by Get-ProductServlet.Lines 1-14

  14. 1 <?xml version = "1.0"?> 2 3 <!-- ProductDetails.xsl --> 4 <!-- XSLT stylesheet for transforming content generated by --> 5 <!-- GetProductServlet into XHTML. --> 6 7 <xsl:stylesheet version = "1.0" 8 xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> 9 10 <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"/> 13 14 <!-- include template for processing error elements --> 15 <xsl:include href = "/XSLT/XHTML/error.xsl"/> 16 17 <!-- template for product element --> 18 <xsl:template match = "product"> 19 <html xmlns = "http://www.w3.org/1999/xhtml" 20 xml:lang = "en" lang = "en"> 21 22 <head> 23 <title> 24 <xsl:value-of select = "title"/> -- Description 25 </title> 26 27 <link rel = "StyleSheet" href = "styles/default.css"/> 28 </head> 29 30 <body> 31 32 <!-- copy navigation header into XHTML document --> 33 <xsl:for-each select = 34 "document( '/XSLT/XHTML/navigation.xml' )"> 35 <xsl:copy-of select = "."/> Fig. 17.4 XSL transformation for generating XHTML from GetProduct-Servlet (part 1).Lines 1-92 Extract relevant pieces of information from the XML document to create appropriate XHTML representation

  15. 36 </xsl:for-each> 37 38 <div class = "header"> 39 <xsl:value-of select = "title"/> 40 </div> 41 42 <div class = "author"> 43 by <xsl:value-of select = "author"/> 44 </div> 45 46 <!-- create div element with details of Product --> 47 <div class = "productDetails"> 48 <table style = "width: 100%;"> 49 <tr> 50 <td style = "text-align: center;"> 51 <img class = "bookCover" 52 src = "images/{image}" 53 alt = "{title} cover image."/> 54 </td> 55 56 <td> 57 <p style = "text-align: right;"> 58 Price: <xsl:value-of select = "price"/> 59 </p> 60 61 <p style = "text-align: right;"> 62 ISBN: <xsl:value-of select = "ISBN"/> 63 </p> 64 65 <p style = "text-align: right;"> 66 Pages: <xsl:value-of select = "pages"/> 67 </p> 68 Fig. 17.4 XSL transformation for generating XHTML from GetProduct-Servlet (part 2).

  16. 69 <p style = "text-align: right;"> 70 Publisher: 71 <xsl:value-of select = "publisher"/> 72 </p> 73 74 <!-- AddToCart button --> 75 <form method = "post" action = "AddToCart"> 76 <p style = "text-align: center;"> 77 <input type = "submit" 78 value = "Add to cart"/> 79 80 <input type = "hidden" name = "ISBN" 81 value = "{ISBN}"/> 82 </p> 83 </form> 84 </td> 85 </tr> 86 </table> 87 </div> 88 89 </body> 90 </html> 91 </xsl:template> 92 </xsl:stylesheet> Fig. 17.4 XSL transformation for generating XHTML from GetProduct-Servlet (part 3).

  17. 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 "DTD/xhtml1-strict.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml" 5 lang="en" xml:lang="en"> 6 <head> 7 <title>XML How to Program -- Description</title> 8 <link href="styles/default.css" rel="StyleSheet" /> 9 </head> 10 <body> 11 <div> 12 <div class="logo"> 13 <table style="width: 100%;"> 14 <tr> 15 <td style="text-align: left;"> 16 <img src="images/logotiny.gif" 17 alt="Deitel &amp; Associates, Inc. logo." /> 18 </td> 19 20 <td style="text-align: right;"> 21 <div style= 22 "position: relative; bottom: -50px;"> 23 <form action="ProductSearch" method="get"> 24 <p><input type="text" size="15" 25 name="searchString" /> 26 <input type="submit" value="Search" /> 27 </p> 28 </form> 29 </div> 30 </td> 31 </tr> 32 </table> 33 </div> 34 Fig. 17.5 XHTML document generated by XSLT in Get-ProductServlet (part 1).

  18. 35 <div class="navigation"> 36 <table class="menu"> 37 <tr> 38 <td class="menu"> 39 <a href="GetAllProducts">Product Catalog</a> 40 </td> 41 42 <td class="menu"> 43 <a href="registration.html">Create Account</a> 44 </td> 45 46 <td class="menu"> 47 <a href="login.html">Log in</a> 48 </td> 49 50 <td class="menu"> 51 <a href="ViewCart">Shopping Cart</a> 52 </td> 53 54 <td class="menu"> 55 <a href="ViewOrderHistory">Order History</a> 56 </td> 57 </tr> 58 </table> 59 </div> 60 61 </div> 62 <div class="header">XML How to Program</div> 63 <div class="author"> 64 by Deitel, Deitel, Nieto, Lin &amp; Sadhu</div> 65 <div class="productDetails"> 66 <table style="width: 100%;"> 67 <tr> 68 <td style="text-align: center;"> Fig. 17.5 XHTML document generated by XSLT in Get-ProductServlet (part 2).

  19. 69 <img alt="XML How to Program cover image." 70 src="images/xmlhtp1.jpg" 71 class="bookCover" /></td> 72 <td> 73 <p style="text-align: right;"> 74 Price: $69.95</p> 75 <p style="text-align: right;"> 76 ISBN: 0130284173</p> 77 <p style="text-align: right;"> 78 Pages: 1100</p> 79 <p style="text-align: right;"> 80 Publisher: Prentice Hall</p> 81 82 <form action="AddToCart" method="post"> 83 <p style="text-align: center;"> 84 <input value="Add to cart" 85 type="submit" /> 86 <input value="0130284173" 87 name="ISBN" type="hidden" /></p> 88 </form> 89 </td> 90 </tr> 91 </table> 92 </div> 93 </body> 94 </html> Fig. 17.5 XHTML document generated by XSLT in Get-ProductServlet (part 3).

  20. Fig. 17.5 XHTML document generated by XSLT in Get-ProductServlet (part 4).

  21. 1 <?xml version = "1.0"?> 2 3 <xsl:stylesheet version = "1.0" 4 xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> 5 6 <xsl:output method = "xml" omit-xml-declaration = "no" 7 doctype-system = "http://www.wapforum.org/DTD/wml_1.1.xml" 8 doctype-public = "-//WAPFORUM//DTD WML 1.1//EN"/> 9 10 <xsl:include href = "/XSLT/WML/error.xsl"/> 11 12 <xsl:template match = "product"> 13 <wml> 14 15 <card id = "product" title = "{title}"> 16 <do type = "accept" label = "Add To Cart"> 17 <go href = "AddToCart" method = "post"> 18 <postfield name = "ISBN" value = "{ISBN}"/> 19 </go> 20 </do> 21 22 <do type = "prev" label = "Back"> 23 <prev/> 24 </do> 25 26 <p>Description:</p> 27 <p><xsl:value-of select = "title"/></p> 28 <p>by <xsl:value-of select = "author"/></p> 29 30 <p> 31 <table columns = "2" title = "info"> 32 <tr> 33 <td>ISBN: 34 <xsl:value-of select = "ISBN"/> 35 </td> Fig. 17.6 XSL transformation for generating WML from GetProduct-Servlet (part 1).Lines 1-54 Extract relevant pieces of information from the XML document to create appropriate WML representation

  22. 36 <td>Price: 37 $<xsl:value-of select = "price"/> 38 </td> 39 </tr> 40 <tr> 41 <td>Publisher: 42 <xsl:value-of select = "publisher"/> 43 </td> 44 <td>Pages: 45 <xsl:value-of select = "pages"/> 46 </td> 47 </tr> 48 </table> 49 </p> 50 </card> 51 52 </wml> 53 </xsl:template> 54 </xsl:stylesheet> Fig. 17.6 XSL transformation for generating WML from GetProduct-Servlet (part 2).

  23. 1 <?xml version="1.0"?> 2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 3 "http://www.wapforum.org/DTD/wml_1.1.xml"> 4 5 <wml> 6 <card title="XML How to Program" id="product"> 7 <do label="Add To Cart" type="accept"> 8 <go method="post" href="AddToCart"> 9 <postfield value="0130284173" name="ISBN"/></go> 10 </do> 11 <do label="Back" type="prev"><prev/></do> 12 13 <p>Description:</p> 14 <p>XML How to Program</p> 15 <p>by Deitel, Deitel, Nieto, Lin &amp; Sadhu</p> 16 <p> 17 <table title="info" columns="2"> 18 <tr> 19 <td>ISBN: 0130284173</td> 20 <td>Price: $$69.95</td> 21 </tr> 22 <tr> 23 <td>Publisher: Prentice Hall</td> 24 <td>Pages: 1100</td> 25 </tr> 26 </table> 27 </p> 28 </card> 29 </wml> Fig. 17.7 WML document generated by XSLT in Get-ProductServlet (part 1).Lines 1-29 WML document contains little formatting information, because display capabilities are limited

  24. Fig. 17.7 WML document generated by XSLT in Get-ProductServlet (part 2).

  25. 1 <?xml version = "1.0"?> 2 3 <xsl:stylesheet version = "1.0" 4 xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> 5 6 <xsl:output method = "html" 7 omit-xml-declaration = "yes" 8 indent = "yes" 9 doctype-system = 10 "http://www.w3.org/MarkUp/html-spec/html-spec_toc.html" 11 doctype-public = "-//W3C//DTD HTML 2.0//EN"/> 12 13 <xsl:include href = "/XSLT/cHTML/error.xsl"/> 14 15 <xsl:template match = "product"> 16 <html> 17 18 <head> 19 <title> 20 <xsl:value-of select = "title"/> -- Description 21 </title> 22 </head> 23 24 <body> 25 <div class = "header"> 26 <xsl:value-of select = "title"/> 27 </div> 28 29 <div class = "author"> 30 by <xsl:value-of select = "author"/> 31 </div> 32 Fig. 17.8 XSL transformation for generating cHTML from GetProduct-Servlet (part 1).Lines 1-78 Extract relevant pieces of information from the XML document to create appropriate cHTML representation

  26. 33 <!-- create div element with details of Product --> 34 <div class = "productDetails"> 35 <table> 36 <tr> 37 <td style = "text-align: center;"> 38 <img class = "bookCover" 39 src = "images/{image}"/> 40 </td> 41 42 <td> 43 <p style = "text-align: right;"> 44 Price: <xsl:value-of select = "price"/> 45 </p> 46 47 <p style = "text-align: right;"> 48 ISBN: <xsl:value-of select = "ISBN"/> 49 </p> 50 51 <p style = "text-align: right;"> 52 Pages: <xsl:value-of select = "pages"/> 53 </p> 54 55 <p style = "text-align: right;"> 56 Publisher: 57 <xsl:value-of select = "publisher"/> 58 </p> 59 60 <!-- AddToCart button --> 61 <form method="post" action="AddToCart"> 62 <p style = "text-align: center;"> 63 <input type = "submit" 64 value = "Add to cart"/> 65 </p> 66 Fig. 17.8 XSL transformation for generating cHTML from GetProduct-Servlet (part 2).

  27. 67 <input type = "hidden" name = "ISBN" 68 value = "{ISBN}"/> 69 </form> 70 </td> 71 </tr> 72 </table> 73 </div> 74 </body> 75 76 </html> 77 </xsl:template> 78 </xsl:stylesheet> Fig. 17.8 XSL transformation for generating cHTML from GetProduct-Servlet (part 3).

  28. 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 2.0//EN" 2 "http://www.w3.org/MarkUp/html-spec/html-spec_toc.html"> 3 <html> 4 <head> 5 <META http-equiv="Content-Type" 6 content="text/html; charset=UTF-8"> 7 <title>XML How to Program -- Description</title> 8 </head> 9 <body> 10 <div class="header">XML How to Program</div> 11 <div class="author"> 12 by Deitel, Deitel, Nieto, Lin &amp; Sadhu</div> 13 <div class="productDetails"> 14 <table> 15 <tr> 16 <td style="text-align: center;"> 17 <img src="images/xmlhtp1.jpg" class="bookCover"> 18 </td> 19 <td> 20 <p style="text-align: right;">Price: $69.95</p> 21 22 <p style="text-align: right;">ISBN: 0130284173</p> 23 24 <p style="text-align: right;">Pages: 1100</p> 25 26 <p style="text-align: right;"> 27 Publisher: Prentice Hall</p> 28 29 <form action="AddToCart" method="post"> 30 <p style="text-align: center;"> 31 <input value="Add to cart" type="submit"> 32 </p> 33 <input value="0130284173" name="ISBN" 34 type="hidden"> 35 </form> Fig. 17.9 cHTML document generated by XSLT in Get-ProductServlet (part 1).

  29. 36 </td> 37 </tr> 38 </table> 39 </div> 40 </body> 41 </html> Fig. 17.9 cHTML document generated by XSLT in Get-ProductServlet (part 2).

More Related