Top Banner
Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design Modeling Web Application using UML Application Server Web Application Design
73

Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design Modeling Web Application using UML Application Server Web Application.

Dec 23, 2015

Download

Documents

George Parsons
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 1

Chapter 8 - Web Application System Design Modeling Web Application using UML Application Server Web Application Design

Page 2: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 2

Modeling Web Applicationusing UML

Page 3: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 3

8.1 - Modeling Web Application using UML Modeling Web Pages Modeling EJB

Page 4: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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 .

Page 5: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 5

Modeling Web Pages

Page 6: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 6

Modeling Web Pages

Page 7: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 7

Modeling Web Pages

Page 8: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 8

Modeling Web Pages

Page 9: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 9

Modeling Web Pages

Page 10: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 11: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 11

Modeling EJB as a subsystem

Page 12: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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)

Page 13: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 13

Modeling EJB as a subsystem

Page 14: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 14

Modeling EJB as a subsystem

Page 15: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 15

Modeling EJB as a subsystem

Page 16: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 16

Modeling EJB as a subsystem

Page 17: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 17

Standard UML-Java Mapping

Page 18: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 18

Sun JSR-000026 UML/EJB Mapping

Page 19: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 19

Application Server

Page 20: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 20

8.2 - Application Server Application Servers J2EE Application Servers Web Server and Application Server

Page 21: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 21

Application Servers In the beginning, there was darkness and

cold. Then, …

Centralized, non-distributed

terminals

mainframe

terminals

Page 22: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 22

Application Servers The In the 90' s, systems should be client-

server

Page 23: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 23

Application ServersToday, enterprise applications use

the multi-tier model

Page 24: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 25: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 26: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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)

Page 27: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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)

Page 28: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 28

Web Application Design

Page 29: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 30: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 30

Application Layer

Page 31: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 31

Business Layer

Page 32: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 32

J2EE Multi-tier Model

Page 33: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 33

J2EE Application Scenarios Multi-tier typical application

Page 34: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 34

J2EE Application Scenarios Stand-alone client

Page 35: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 35

J2EE Application Scenarios Web-centric application

Page 36: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 36

J2EE Application Scenarios Business-to-business

Page 37: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 37

Main technologies JavaServer Pages (JSP) Servlet Enterprise JavaBeans (EJB)

JSPs, servlets and EJBs are application components

Page 38: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 39: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 40: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 41: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 41

EJB – The Big Picture

Page 42: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 42

EJB at runtime

Client can be local or remote

Page 43: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 43

EJB at runtime

Page 44: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 45: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 46: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 47: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 48: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 49: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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

Page 50: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 50

Examples JSP example Servlet example EJB example

Page 51: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 51

JSP example

Page 52: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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"> &nbsp; </td>

<td width="550">

<h1>My name is Duke. What's yours?</h1>

</td>

</tr>

Page 53: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 53

JSP example<tr> <td width="150" &nbsp; </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>

Page 54: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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>"); }

}

Page 55: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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;}

Page 56: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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;}

Page 57: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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();

}

Page 58: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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(); }

Page 59: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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; }

. . .}

Page 60: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

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!"); } }}

Page 61: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 61

Case Study – Online Bank

Page 62: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 62

Case Study – Online Bank

Page 63: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 63

Case Study – Online Bank

Page 64: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 64

Case Study – Online Bank

Page 65: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 65

Case Study – Online Bank

Page 66: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 66

Case Study – Online Bank

Page 67: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 67

Case Study – Online Bank

Page 68: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 68

Case Study – Online Bank

Page 69: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 69

Case Study – Online Bank

Page 70: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 70

Case Study – Online Bank

Page 71: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 71

Case Study – Online Bank

Page 72: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 72

Case Study – Online Bank

Page 73: Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.

Object Oriented Analysis and Design 73

Case Study – Online Bank