03 Part 2 Dist Obj Design
03 Part 2 Dist Obj Design
Geoff Hambrick
Senior Technical Staff Memeber
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 1 of 50
IBM Software Services for WebSphere
Notations to consider:
textual (state tables, templates)
graphical (state transition and class relationship diagrams)
whatever works for you and your customer
October 28-29, 2003 | Sydney © 2003 IBM Corporation
03_Part_2_Dist_Obj_Design.PRZ 2 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 3 of 50
IBM Software Services for WebSphere
Product Customer
@sku @customerID
description
openOrder
03_Part_2_Dist_Obj_Design.PRZ 4 of 50
IBM Software Services for WebSphere
{create
Product (order) order} ok
Catalog Order Confirm
cancel Details Open
add to order (order)
{add item edit line item submit
(order)
(product, quantity)} Confirm {modify item
Cancel (product, Confirm
ok quantity)} Submit
{cancel order} ok
{submit order}
Action
Result
03_Part_2_Dist_Obj_Design.PRZ 5 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 6 of 50
IBM Software Services for WebSphere
Order
Status Customer
customerID
@customerID
"View" Data in Application Flow Static
orders Model can be produced by Business openOrder
0..n Process Dynamic Model from data
0..n 0..1 customer
Order available in Business Process Static Order
orderID Model @orderID
status
status
03_Part_2_Dist_Obj_Design.PRZ 7 of 50
IBM Software Services for WebSphere
The architecture
describes physical and logical "tiers" where application
components will be hosted
drives the programming model used in detailed design
Remember the four approaches:
web enabled client-server
distributed object based
web services based
web enabled distributed object based
03_Part_2_Dist_Obj_Design.PRZ 8 of 50
IBM Software Services for WebSphere
???
customerID customerID
create() sku customerID
quantity)
HTTP
orderID Customer Shipping description
status Marketing
{create
Product order} ok ship (shipper)
Catalog Order Confirm [all items
products items orders Details Open Entry submit() openOrder
cancel Fulfillment shipped]
add to submit modify line
0..n 0..n 0..n order Completed purge
edit line item item product 0..n 0..1 customer
[qty < 0] cancel()
Product Line Item Order Action Confirm Confirm (product,
Result Action [qty = 0] Cancel {modify item Confirm
Submit quantity)
[not all items Line Item Order
productID productID orderID message orderID {add item ok
(product, pack line item shipped] 0..n
description description status action (product, quantity)} (product, quantity) quantity orderID
quantity {cancel order}
quantity)} ok status
Action {submit order}
Result
Pros:
browsers are everywhere
client tier needs install nothing specific (maintenance)
middle tier has direct access to back end data (performance)
Cons:
cost of remote connection to middle tier (performance)
must install enterprise clients on middle tier (maintenance)
business logic executes in middle tier (security)
Best application:
web enabling the front end of a business process (the "edge")
03_Part_2_Dist_Obj_Design.PRZ 9 of 50
IBM Software Services for WebSphere
IIOP
(order) open
???
customerID customerID
create() sku customerID
orderID quantity) Shipping
Customer description
status Marketing
{create
Product order} ok ship (shipper)
Catalog Order Confirm [all items
products items orders Details Open Entry submit() openOrder
cancel Fulfillment shipped]
add to submit modify line
0..n 0..n 0..n order Completed purge
edit line item item product 0..n 0..1 customer
[qty < 0] cancel()
Product Line Item Order Action Confirm Confirm (product,
Result Action [qty = 0] Cancel {modify item Confirm
Submit quantity)
[not all items Line Item Order
productID productID orderID message orderID {add item ok
(product, pack line item shipped] 0..n
description description status action (product, quantity)} (product, quantity) quantity orderID
quantity {cancel order}
quantity)} ok status
Action {submit order}
Result
Pros:
really snappy user interface (performance)
client does not need enterprise access
business logic separated from client (security, maintenance)
can load balance business logic (scalability)
Cons:
must install application on client (maintenance)
extra pathlength to access enterprise (performance)
ORBs are not yet ubiquitous (maintenance)
Best application:
intranet applications needing high function a GUI
03_Part_2_Dist_Obj_Design.PRZ 10 of 50
IBM Software Services for WebSphere
HTTP
(order) open
???
customerID customerID
create() sku customerID
orderID
quantity) Shipping
Customer description
status
{create
Marketing
Product order} ok ship (shipper)
Catalog Order Confirm [all items
products items orders Details Open Entry submit() openOrder
cancel Fulfillment shipped]
add to submit modify line
0..n 0..n 0..n order Completed purge
edit line item [qty < 0] item product 0..n 0..1 customer
Action Confirm Confirm cancel()
Product Line Item Order (product,
Result Action [qty = 0] Cancel {modify item Confirm
Submit quantity)
[not all items Line Item Order
productID productID orderID message orderID {add item ok
(product, pack line item shipped] 0..n
description description status action (product, quantity)} (product, quantity) quantity orderID
quantity {cancel order}
quantity)} ok status
Action {submit order}
Result
03_Part_2_Dist_Obj_Design.PRZ 11 of 50
IBM Software Services for WebSphere
HTTP IIOP
(order) open
???
customerID customerID create() sku customerID
orderID
quantity) Shipping
Customer description
status
{create
Marketing
Product order} ok ship (shipper)
Catalog Order Confirm [all items
products items orders Details Open Entry submit() openOrder
cancel Fulfillment shipped]
add to submit modify line
0..n 0..n 0..n order Completed purge
edit line item [qty < 0] item product 0..n 0..1 customer
Action Confirm Confirm cancel()
Product Line Item Order (product,
Result Action [qty = 0] Cancel {modify item Confirm
Submit quantity)
[not all items Line Item Order
productID productID orderID message orderID {add item ok
(product, pack line item shipped] 0..n
description description status action (product, quantity)} (product, quantity) quantity orderID
quantity {cancel order}
quantity)} ok status
Action {submit order}
Result
Pros:
client tier needs install nothing specific (maintenance)
middle tier does not need enterprise clients (maintenance)
business logic separated from application server (security)
can load balance application & object servers (scalability)
Cons:
remote method pathlength (performance)
Best application:
web enabling any phase of a business process
03_Part_2_Dist_Obj_Design.PRZ 12 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 13 of 50
IBM Software Services for WebSphere
HTTP
(product,
IIOP
(order) open
???
customerID customerID create() sku customerID
orderID
quantity) Shipping
Customer description
status Marketing
{create
Product order} ok ship (shipper)
Catalog Order Confirm [all items
products items orders Details Open Entry submit() openOrder
cancel Fulfillment shipped]
add to submit modify line
0..n 0..n 0..n order Completed purge
edit line item [qty < 0] item product 0..n 0..1 customer
Action Confirm Confirm cancel()
Product Line Item Order (product,
Result Action [qty = 0] Cancel {modify item Confirm [not all items Line Item Order
Submit quantity)
productID productID orderID message orderID {add item ok
(product, pack line item shipped] 0..n
description description status action quantity)} (product, quantity) quantity orderID
(product, {cancel order}
quantity ok
quantity)} status
Action {submit order}
Result
03_Part_2_Dist_Obj_Design.PRZ 14 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 15 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 16 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 17 of 50
IBM Software Services for WebSphere
Product Customer
sku customerID
description
openOrder
03_Part_2_Dist_Obj_Design.PRZ 18 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 19 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 20 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 21 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 22 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 23 of 50
IBM Software Services for WebSphere
Product Customer
sku customerID
description
openOrder
03_Part_2_Dist_Obj_Design.PRZ 24 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 25 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 26 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 27 of 50
IBM Software Services for WebSphere
HTTP
(product,
IIOP
(order) open
???
customerID customerID create() sku customerID
orderID
quantity) Shipping
Customer description
status Marketing
{create
Product order} ok ship (shipper)
Catalog Order Confirm [all items
products items orders Details Open Entry submit() openOrder
cancel Fulfillment shipped]
add to submit modify line
0..n 0..n 0..n order Completed purge
edit line item [qty < 0] item product 0..n 0..1 customer
Action Confirm Confirm cancel()
Product Line Item Order (product,
Result Action [qty = 0] Cancel {modify item Confirm [not all items Line Item Order
Submit quantity)
productID productID orderID message orderID {add item ok
(product, pack line item shipped] 0..n
description description status action quantity)} (product, quantity) quantity orderID
(product, {cancel order}
quantity ok
quantity)} status
Action {submit order}
Result
03_Part_2_Dist_Obj_Design.PRZ 28 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 29 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 30 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 31 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 32 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 33 of 50
IBM Software Services for WebSphere
Entity EJB
Data with indentity - primary key
Relationships to other entities - Employee/Department
If CMP then all persistence handled by container.
03_Part_2_Dist_Obj_Design.PRZ 34 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 35 of 50
IBM Software Services for WebSphere
Product Customer
sku customerID
description
openOrder
03_Part_2_Dist_Obj_Design.PRZ 36 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 37 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 38 of 50
IBM Software Services for WebSphere
[home =
OrderHome]
home.findByPrimaryKey(1000)
advantage 2: {find Order Entity EJB and
simplifies client load CMP fields}
code Order
getOrderDetails()
1 n
advantage 1: new(v , ..., v )
minimizes 1 1 n n
remoteable calls [p =v , ..., p =v ]
OrderDetailsData
OrderDetailsData
03_Part_2_Dist_Obj_Design.PRZ 39 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 40 of 50
IBM Software Services for WebSphere
Customer
Home Order
Product Customer
Product Order Order Customer Status add line item
Catalog Details Status Home (order) open (product, sku customerID
customerID create()
customerID quantity) description
orderID Customer Shipping
status {create Marketing
Product order} ok ship (shipper)
Catalog Order Confirm
products items orders Details Open Entry submit() [all items openOrder
add to cancel submit Fulfillment shipped]
0..n order modify line
0..n 0..n edit line item Completed purge
Confirm
[qty < 0] item cancel() product 0..n 0..1 customer
Product Line Item Order Action Confirm Cancel Confirm (product,
Result Action [qty = 0] {modify item [not all items
productID {add item (product,
Submit quantity)
pack line item shipped] Line Item Order
productID orderID message orderID ok quantity)}
description description status action (product, {cancel order} (product, quantity) 0..n
quantity quantity)} ok quantity
Action {submit order}
orderID
Result status
03_Part_2_Dist_Obj_Design.PRZ 41 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 42 of 50
IBM Software Services for WebSphere
Local Home(factory)
public interface StockLocalHome extends Deployment Descriptor
javax.ejb.EJBLocalHome { <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>DemoEJB</display-name>
public ubs.wine.entity.StockLocal
<enterprise-beans>
<session id="Cellar">
<ejb-name>Cellar</ejb-name>
<home>ubs.wine.session.CellarHome</home>
<remote>ubs.wine.session.Cellar</remote>
<ejb-class>ubs.wine.session.CellarBean</ejb-class>
03_Part_2_Dist_Obj_Design.PRZ 43 of 50
IBM Software Services for WebSphere
StockLocal stock =
*
stockHome.findByPrimaryKey(stockid); *
Stock
StockId 1
* Order
StockCB stockDetails = new StockCB(); Vintage OrderId
Price Cost
stockDetails.populate(stock); QuantityInStock
return
// ... stockDetails.toString();
} public class StockCB implements Serializable {
} public void populate(StockLocal stockEntity) { Cargo
setYear( stockEntity.getYear() );
setPrice( stockEntity.getPrice());
population
setQuantityInStock( stockEntity.getCases() );
setChateau( stockEntity.getWineforstock().getChateau() );
setWineName( stockEntity.getWineforstock().getName() );
03_Part_2_Dist_Obj_Design.PRZ 44 of 50
IBM Software Services for WebSphere
Monitor
Performance monitoring hooks
Optimise
By Caching
By improving Data Access
Improve Application
Performance Without
Code Change
03_Part_2_Dist_Obj_Design.PRZ 45 of 50
IBM Software Services for WebSphere
stockHome.findByPrimaryKey(stockid);
setYear( stockEntity.getYear() );
setPrice( stockEntity.getPrice());
setQuantityInStock( stockEntity.getCases() );
setChateau( stockEntity.getWineforstock().getChateau() );
setWineName( stockEntity.getWineforstock().getName() );
03_Part_2_Dist_Obj_Design.PRZ 46 of 50
IBM Software Services for WebSphere
stockEntity == findByPrimaryKey(stockid)
stockEntity findByPrimaryKey(stockid)
stockEntity.getYear()
stockEntity.getPrice() wine
stockEntity.getWineforstock().getChateau()
stockEntity.getWineforstock().getChateau()
stockEntity.getWineforstock().getName()
03_Part_2_Dist_Obj_Design.PRZ 47 of 50
IBM Software Services for WebSphere
stockEntity == findByPrimaryKey(stockid)
findByPrimaryKey(stockid) Use a ReadAhead hint to say
stockEntity
When you findByPrimaryKey also
stockEntity.getYear()
prefetch the associated Wine
stockEntity.getPrice()
stockEntity.getWineforstock().getChateau()
stockEntity.getWineforstock().getName()
stock wine
StockHome
Select * from Stock, Wine Wine
WineId
where stockId = ? Chateau
Name
Stock
StockId
Vintage
Price
QuantityInStock
03_Part_2_Dist_Obj_Design.PRZ 48 of 50
IBM Software Services for WebSphere
Role
Page Producer Application Assembler Bean Builder Deployer
03_Part_2_Dist_Obj_Design.PRZ 49 of 50
IBM Software Services for WebSphere
03_Part_2_Dist_Obj_Design.PRZ 50 of 50