Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design Modeling Web Application using UML Application Server Web Application Design
Dec 23, 2015
Object Oriented Analysis and Design 1
Chapter 8 - Web Application System Design Modeling Web Application using UML Application Server Web Application Design
Object Oriented Analysis and Design 2
Modeling Web Applicationusing UML
Object Oriented Analysis and Design 3
8.1 - Modeling Web Application using UML Modeling Web Pages Modeling EJB
Object Oriented Analysis and Design 4
Modeling Web Pages For web pages, the stereotypes indicate that the
class is an abstraction of the logical behavior of a web page on either the client or the server. The two abstractions are related to each other with a directional relationship between the two. This association is stereotyped as «build», since it can be said that a server page builds a client page .
Object Oriented Analysis and Design 5
Modeling Web Pages
Object Oriented Analysis and Design 6
Modeling Web Pages
Object Oriented Analysis and Design 7
Modeling Web Pages
Object Oriented Analysis and Design 8
Modeling Web Pages
Object Oriented Analysis and Design 9
Modeling Web Pages
Object Oriented Analysis and Design 10
Modeling EJB Modeling EJB as a subsystem Two approach:
Standard UML-Java Mapping Sun JSR-000026 UML/EJB Mapping
Object Oriented Analysis and Design 11
Modeling EJB as a subsystem
Object Oriented Analysis and Design 12
Modeling EJB as a subsystemICustomerMgt => CustomerHome (home interface)
Icustomer => Customer (remote interface)
<<subsystem proxy>>Customer =>CustomerEJB (bean class)
validateCustomer() => findUser() (in home interface)
Object Oriented Analysis and Design 13
Modeling EJB as a subsystem
Object Oriented Analysis and Design 14
Modeling EJB as a subsystem
Object Oriented Analysis and Design 15
Modeling EJB as a subsystem
Object Oriented Analysis and Design 16
Modeling EJB as a subsystem
Object Oriented Analysis and Design 17
Standard UML-Java Mapping
Object Oriented Analysis and Design 18
Sun JSR-000026 UML/EJB Mapping
Object Oriented Analysis and Design 19
Application Server
Object Oriented Analysis and Design 20
8.2 - Application Server Application Servers J2EE Application Servers Web Server and Application Server
Object Oriented Analysis and Design 21
Application Servers In the beginning, there was darkness and
cold. Then, …
Centralized, non-distributed
terminals
mainframe
terminals
Object Oriented Analysis and Design 22
Application Servers The In the 90' s, systems should be client-
server
Object Oriented Analysis and Design 23
Application ServersToday, enterprise applications use
the multi-tier model
Object Oriented Analysis and Design 24
Application Servers " The Multi- tier applications" have several
independent components An application server provides the
infrastructure and services to run such applications
Object Oriented Analysis and Design 25
Application Servers Application server products can be separated
into 3 categories: J2EE-based solutions Non-J2EE solutions (PHP, ColdFusion, Perl, etc.) And the Microsoft solution (ASP/COM and
now .NET with ASP.NET, VB.NET, C#, etc.)
Object Oriented Analysis and Design 26
J2EE Application Servers Major J2EE products:
BEA WebLogic IBM WebSphere Sun iPlanet Application Server Oracle 9iAS HP/Bluestone Total-e-Server Borland AppServer Jboss (free open source)
Object Oriented Analysis and Design 27
Web Server and Application Server
Web Server
(HTTP Server)
App Server 1
App Server 2
Internet Browser
HTTP(S)
Object Oriented Analysis and Design 28
Web Application Design
Object Oriented Analysis and Design 29
8.3 - Web Application Design Application Layer Business Layer J2EE Multi-tier Model J2EE Application Scenarios Main Technologies Examples Case Study –Online Bank
Object Oriented Analysis and Design 30
Application Layer
Object Oriented Analysis and Design 31
Business Layer
Object Oriented Analysis and Design 32
J2EE Multi-tier Model
Object Oriented Analysis and Design 33
J2EE Application Scenarios Multi-tier typical application
Object Oriented Analysis and Design 34
J2EE Application Scenarios Stand-alone client
Object Oriented Analysis and Design 35
J2EE Application Scenarios Web-centric application
Object Oriented Analysis and Design 36
J2EE Application Scenarios Business-to-business
Object Oriented Analysis and Design 37
Main technologies JavaServer Pages (JSP) Servlet Enterprise JavaBeans (EJB)
JSPs, servlets and EJBs are application components
Object Oriented Analysis and Design 38
JSP Used for web pages with dynamic content Processes HTTP requests (non-blocking call-and-
return) Accepts HTML tags, special JSP tags, and
scriptlets of Java code Separates static content from presentation logic Can be created by web designer using HTML tools
Object Oriented Analysis and Design 39
Servlet Used for web pages with dynamic content Processes HTTP requests (non-blocking call-
and-return) Written in Java; uses print statements to render
HTML Loaded into memory once and then called many
times Provides APIs for session management
Object Oriented Analysis and Design 40
EJB EJBs are distributed components used to
implement business logic (no UI) Developer concentrates on business logic Availability, scalability, security,
interoperability and integrability handled by the J2EE server
Client of EJBs can be JSPs, servlets, other EJBs and external aplications
Clients see interfaces
Object Oriented Analysis and Design 41
EJB – The Big Picture
Object Oriented Analysis and Design 42
EJB at runtime
Client can be local or remote
Object Oriented Analysis and Design 43
EJB at runtime
Object Oriented Analysis and Design 44
Types of EJB
EJB Taxonomy
Sta te ful
Sta te le ss
Se ssionBea n
BMP
C MP
EntityBea n M essa geDrivenBea n
Ente rp riseBea n
Object Oriented Analysis and Design 45
Session Bean Stateful session bean:
Retains conversational state (data) on behalf of an individual client
If state changed during this invocation, the same state will be available upon the following invocation
Example: shopping cart
Object Oriented Analysis and Design 46
Session Bean Stateless session bean:
Contains no user-specific data Business process that provides a generic
service Container can pool stateless beans Example: shopping catalog
Object Oriented Analysis and Design 47
Entity Bean Represents business data stored in a database ?
persistent object Underlying data is normally one row of a table A primary key uniquely identifies each bean
instance Allows shared access from multiple clients The Can live past the duration of client' s
session Example: shopping order
Object Oriented Analysis and Design 48
Entity Bean Bean-managed persistence (BMP): bean
developer writes JDBC code to access the database; allows better control for the developer
Container-managed persistence (CMP): container generates all JDBC code to access the database; developer has less code to write, but also less control
Object Oriented Analysis and Design 49
Message-Driven Bean Message consumer for a JMS queue or
topic Benefits from EJB container services that
are not available to standard JMS consumers
Has no home or remote interface Example: Order processing – stock info
Object Oriented Analysis and Design 50
Examples JSP example Servlet example EJB example
Object Oriented Analysis and Design 51
JSP example
Object Oriented Analysis and Design 52
JSP example<%@ page import="hello.Greeting" %>
<jsp:useBean id="mybean" scope="page" class="hello.Greeting"/>
<jsp:setProperty name="mybean" property="*" />
<html>
<head><title>Hello, User</title></head>
<body bgcolor="#ffffff" background="background.gif">
<%@ include file="dukebanner.html" %>
<table border="0" width="700">
<tr>
<td width="150"> </td>
<td width="550">
<h1>My name is Duke. What's yours?</h1>
</td>
</tr>
Object Oriented Analysis and Design 53
JSP example<tr> <td width="150" </td> <td width="550"><form method="get"><input type="text" name="username" size="25"> <br><input type="submit" value="Submit"><input type="reset" value="Reset"></td> </tr></form> </table><% if (request.getParameter("username") != null) {%><%@ include file="response.jsp" %><% }%></body></html>
Object Oriented Analysis and Design 54
Servlet examplepublic class HelloWorldServlet extends HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("<html><head><title>Hello World Servlet</title></head>"); out.println("<body><h1>Hello World!</h1></body></html>"); }
}
Object Oriented Analysis and Design 55
EJB Example// Shopping Cart example
// Home interface public interface CartHome extends EJBHome {
Cart create(String person) throws RemoteException, CreateException;
Cart create(String person, String id) throws RemoteException, CreateException;}
Object Oriented Analysis and Design 56
EJB Example// Remote interfacepublic interface Cart extends EJBObject {
public void addBook(String title) throws RemoteException;
public void removeBook(String title) throws BookException, RemoteException;
public Vector getContents() throws RemoteException;}
Object Oriented Analysis and Design 57
EJB Example// Enterprise bean class
public class CartEJB implements SessionBean {
String customerName, customerId;
Vector contents;
private SessionContext sc;
public void ejbCreate(String person) throws CreateException {
if (person == null) {
throw new CreateException("Null person not allowed.");
}
else {
customerName = person;
}
customerId = "0";
contents = new Vector();
}
Object Oriented Analysis and Design 58
EJB Example public void ejbCreate(String person, String id) throws CreateException { if (person == null) { throw new CreateException("Null person not allowed."); } else { customerName = person; } IdVerifier idChecker = new IdVerifier(); if (idChecker.validate(id)) { customerId = id; } else { throw new CreateException("Invalid id: " + id); } contents = new Vector(); }
Object Oriented Analysis and Design 59
EJB Example public void addBook(String title) { contents. addElement(title); }
public void removeBook(String title) throws BookException { boolean result = contents.removeElement(title); if (result == false) { throw new BookException(title + " not in cart."); } }
public Vector getContents() { return contents; }
. . .}
Object Oriented Analysis and Design 60
EJB Example// EJB client (stand-alone application)public class CartClient { public static void main(String[] args) { try { CartHome home = (CartHome)initial.lookup("MyCart"); Cart shoppingCart = home.create("Duke DeEarl", "123"); shoppingCart.addBook("The Martian Chronicles"); shoppingCart.addBook("2001 A Space Odyssey"); shoppingCart.remove(); } catch (BookException ex) { System.err.println("Caught a BookException: " + ex.getMessage()); } catch (Exception ex) { System.err.println("Caught an unexpected exception!"); } }}
Object Oriented Analysis and Design 61
Case Study – Online Bank
Object Oriented Analysis and Design 62
Case Study – Online Bank
Object Oriented Analysis and Design 63
Case Study – Online Bank
Object Oriented Analysis and Design 64
Case Study – Online Bank
Object Oriented Analysis and Design 65
Case Study – Online Bank
Object Oriented Analysis and Design 66
Case Study – Online Bank
Object Oriented Analysis and Design 67
Case Study – Online Bank
Object Oriented Analysis and Design 68
Case Study – Online Bank
Object Oriented Analysis and Design 69
Case Study – Online Bank
Object Oriented Analysis and Design 70
Case Study – Online Bank
Object Oriented Analysis and Design 71
Case Study – Online Bank
Object Oriented Analysis and Design 72
Case Study – Online Bank
Object Oriented Analysis and Design 73
Case Study – Online Bank