• No results found

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

N/A
N/A
Protected

Academic year: 2021

Share "How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer"

Copied!
47
0
0

Loading.... (view fulltext now)

Full text

(1)

How to Build an E-Commerce Application

using J2EE

Carol McDonald Code Camp Engineer

(2)

Code Camp

Agenda

• J2EE™ & Blueprints

– Application Architecture and J2EE

– Blueprints E-Commerce Application Design

• Enterprise JavaBeans™ (EJB™)

– Designing and implementing the Business Model:

• Entity Beans, Stateless and Stateful Session Beans

• Servlets , Java ServerPages™ (JSP™)

– Designing and architecting the "View" or Presentation logic

• Assembling and Deploying the J2EE™ Application:

– Transactions JTS™ and JTA™

• Describe how the sample application uses the transaction capabilities of the J2EE™ platform to simplify component development.

– Security How to use J2EE™ security to safeguard your e-commerce application

(3)

Download Code Camps

• All slides with notes are on your CD

• You can download this and other Code Camps :

– EJB, Java Performance, J2ME, JINI, JMS, JSP, XML

http://www.sun.com/developer/evangcentral – under Events: Developer Code Camps

• ALSO

– You can also ask questions there

(4)

J2EE™ & Blueprints

Agenda

Application Architecture and J2EE

• Sun BluePrints™ Design Guidelines

(5)

Architecture and the Cube

Architecting your application Using TiersTiers and

Layers

(6)

Capabilities

Capabilities

= Non-Functional System

Requirements

• AvailabilityAvailability: service is accessible

• ReliabilityReliability: consistency of application and

transactions

• CapacityCapacity: can serve # users

• ExtensibilityExtensibility: can add functionality

• FlexibilityFlexibility: can support changes

• PerformancePerformance: good response time

(7)

Example Architecture Requirements

• E-Commerce Apps: – Many Clients, – lots of reading, – less updating, – low contention

– Need High performance and scalabilityperformance and scalability for Reading data

• Insurance Intranet App:

– Fewer Clients, Low concurrency

– High transaction isolation level, Need Higher Consistency

– ReliabilityReliability of Updates to DB more important than more important

(8)

The Relationships between the Elements of Architecture

Architecting your application Using Tiers and Layers affect the application Capabilities

(9)

J2EE™ Platform Specification

JNDI J2SE JMS RMI/IIOP JDBC Database Database App Client App Client App Client Container App Client Container HTTP/ HTTPS HTTP/ HTTPS J2SE RMI RMI J2SE JNDI JMS RMI/IIOP JDBC JTA JavaMail

JAF JNDI JMS JTA RMI/IIOP JDBC JavaMail JAF HTTP/ HTTPS HTTP/ HTTPS Applet Container Applet Container Applet

Applet JSPJSP ServletServlet EJBEJB

Web Container

Web Container EJB™ ContainerEJB™ Container

RMI

RMI

J2SE

J2SE

Components run within Container.

Container provides Runtime environment, J2SE ™ & J2EE™ APIs, and remote communication

(10)

Layers of Services: The Application Server provides services to the Container, which in turn provides services to the EJB.

Persistence Transactions Naming O R B DB Client Environment Services EJB EJB EJB Container Application Server

Operating System Services

Application Server Services

Application Server Services

Container Services

Container Services

Application

(11)

Layers

• Layers are abstractions of underlying

implementation

• Each Layer hides implementation details of layer below

• The Container provides components services of

the layers below

• Advantages:

– Easier development, maintenance for high performance, scalability

– Does not require developer to know complex details of distributed protocols, concurrency, transactions, load balancing, security, resource pooling and sharing…

(12)

Application Server

: Key Services Dispatching Developer Session Management, Caching Thread Allocation

Applications Servers are

primarily

Resource Managers

Resource Managers

Object Pooling

Applications Servers Manage: dispatching, thread allocation,

(13)

What features might you look for in an

Application Server?

Clustering Load Balancing Transaction Management Security

(14)

EJB Container Services

EJB EJB EJB Container Application Server Transaction Security State Management Persistence Life Cycle Remote Interface Transaction manager

(15)

Components

Monolithic:

1 binary file

Recompiled &

linked for any changes

Components:

• plug-gable Parts.

• Implementation separated from

Interface, only Interface published

• hides implementation details

• Better design, easier updates

(16)
(17)

HTML Web Server RMI / IIOP

Application Server

Data Base

n-tier Architecture with

J2EE

RDBMS PeopleSoft SAP R/3 Legacy Systems network network Browser clients C++, VB.. clients Java clients HTTP Beans Container

(18)

Tiers

• Tiers separate functionality

§ Presentation Logic, Business Logic, Data Schema

• Advantages:

§ One tier can be changed without changing the rest= easier updates

§ Lower deployment and maintenance costs.

§

(19)

Capabilities

Capabilities

Non-Functional

Requirements

Web Server Web Server Web Server App Server App Server App Server R O U T E R

Reliability, Availability, Extensibility,

Reliability, Availability, Extensibility,

Flexibility, Scalability, Goes up

Flexibility, Scalability, Goes up

R O U T E R

With Good Architecture, LayeringLayering, TiersTiers,

(20)

Why J2EE™?

• Gives you the Advantages of a Standardized

Layered

Layered, TierTier Architecture:

• Simplifies the complexity of a building n-tier

applications.

• Standardizes an API between components and application server container.

• J2EE™ Application Server and Containers provide the

(21)

Agenda

J2EE™ & Blueprints

• J2EE Architecture

Sun BluePrintsDesign Guidelines

(22)

The J2EE™ Platform

Has a Rich Set of APIs

Middle Tier EIS Tier Client Client Client Client Other Services: JNDI, JMS, JavaMail™ Enterprise JavaBean Enterprise JavaBean Enterprise Information Systems (EIS): Relational-Database, Legacy Applications, ERP Systems Client Web Server JSP, Servlet, HTML, XML Application Server Client Tier Firewall

(23)

Why J2EE

Blueprints

Rich APIs

More than one way

of

doing things

Similar

Problems

Need to

leverage time-tested

solutions

Don’t reinvent the wheel

Blue

Prints

Provides

Answers

,

(24)

J2EE™ Blueprints

• Guidelines and Best practices for designing n-tier

enterprise applications with J2EE™

• J2EE™ blueprints include:

– Book, Designing Enterprise Applications

– Application (source code)—

• “Java Pet Store”

FREE:

(25)

Blueprints

(26)

J2EE

J2EE

Deliverables

Deliverables

J2EE J2EE

J2EE J2EE™™ Specification Specification J2EE J2EE

Reference Reference Implementation Implementation J2EE J2EE

BluePrints BluePrints J2EE J2EE™™ Compatibility Compatibility Test Suite Test Suite

(27)
(28)

Some Key BluePrints

Questions

-Issues Faced by Developers

When to use

Servlets

verses

JavaServer

Pages

?

Where to store

client session state

:

client-tier, web-tier or EJB

tier?

Access

Data Base Resources

via

EJB

or

directly from

JSP

JavaBean ?

When to use

EJB

components?

When to use

Session Beans

and when to

(29)

Design of Sample Application

Blueprints Choices:

Blueprints Choices:

Client tier

• HTML Clients for End-User Web Access

• XML for Data externalization (Order procurement) Web Server tier

• JavaServer Pages™ (JSP)

for dynamic content generation

Application Server tier

(30)

J2EE™ Blueprints Guidelines

1. Scenarios or Use Cases

2. partitioning of functionality into modules

3. Application architecture using Model-View-Controller:

1. assignment of functionality to tiers:

1. Design of the Model

2. Design of the View

3. Design of the Controller

2. object decomposition within tiers

Process for developing an application from

(31)

1)

Sample Application –

Shopping Scenario

1.

Web-based

browsing

of a product

catalog

2.

Creation and maintenance of a

shopping cart

3.

User

account

creation/ Login

4. Placing orders

5.

Secure order processing

1. B2B transactions

2. Externalisation of order data (expressed in XML)

(32)

1)

Use Case Shopping Scenario

C r e a t e / U p d a t e C u s t o m e r A c c o u n t C u s t o m e r A d d O r d e r t o W a r e h o u s e S y s t e m ( e x t e r n a l ) L o g i n t o C u s t o m e r A c c o u n t S e n d R e c e i p t c h e c k o u t o r d e r i t e m s < < i n c l u d e s > > < < e x t e n d > > < < i n c l u d e s > > B r o w s e C a t a l o g a d d i t e m s t o s h o p p i n g c a r t

(33)

Shopping Scenario Sequence Diagram

: C u s t o m e r C a t a l o g S h o p p i n g C a r t O r d e r I n v e n t o r y M a i l e r C o n t r o l l e r A c c o u n t a d d i t e m t o c a r t a d d i t e m t o c a r t b r o w s e p r o d u c t s c h e c k o u t g e t i t e m s i n c a r t g e t a c c o u n t d e t a i l s c r e a t e o r d e r u p d a t e i n v e n t o r y s e n d e m a i l r e c e i p t

(34)

J2EE™ Blueprints

1. Scenarios or Use Cases

2. partitioning of functionality into modules

3. Application architecture using Model-View-Controller:

1. assignment of functionality to tiers:

1. Design of the Model

2. Design of the View

3. Design of the Controller

2. object decomposition within tiers

Process for developing an application from

(35)

2)

Divide the Application Into Modules

Based on

Services (Functionality)

A c c o u n t User Account Module: tracks user account

information

C a t a l o g Product Catalog Module: provides search

for products, and product details

C a r t Shopping Cart Module: allows user to save

selected items for the session.

O r d e r

Order Processing Module: performs order Processing when user buys the items in the cart.

(36)

2)

Divide the Application Into Modules

Based on

Services

I n v e n t o r y

Inventory Module: maintains information on the number of each type of product in stock.

M a i l Messaging Module: sends confirmation

receipt messages.

C o n t r o l

Control Module: control interactions between user (browse, add items, check out) and business objects.

(37)

Interrelationship of the modules

C o n t r o l C a t a l o g A c c o u n t I n v e n t o r y O r d e r M a i l C a r t browse new/existing account checkout add/remove items User interface

(38)

J2EE™ Blueprints

1. Scenarios or Use Cases

2. partitioning of functionality into modules

3. Application architecture using

Model-View-Controller:

1. assignment of functionality to tiers:

1. Design of the Model

2. Design of the View

3. Design of the Controller

2. object decomposition within tiers

Process for developing an application from

(39)

Divide Application Objects into 3

categories:

• Model View Controller (MVC) UI Pattern

• Model represents the application business data and rules

• View is a screen representation of model, presents the user interface

(40)

Model View Controller Design Pattern

View Controller Model User event Business Event View selection Get Data To Display JSP JavaBeans components Session EJB And Servlet classes Entity EJB and Session EJB

(41)

Assignment of Functionality to Tiers

Assignment of Functionality to Tiers

View Controller Model

Presentation Logic Application Requests Business Services Persistence Domain Objects

(42)

MVC With J2EE™ Technology

• Build ViewView in the Web-tier

• Use JSP™ components for presentation layoutpresentation layout • Custom tags and JavaBeans™ components for

presentation logic

presentation logic

• Build ControllerController in the Web / EJB™ tier

• Servlet for dispatchingdispatching

• Session bean for control within business control within business

objects

objects

• Build ModelModel in the EJB™ tier

• Session beans for Business ServicesBusiness Services: Process

and Rules

(43)

Assignment of Functionality to Tiers

or

Vertical Layering

#A Presentation Control Presentation Layout Business Services Domain Objects Data Access Objects Session Entity DAO Servlet JSP

(44)

What are Domain Objects?

Domain Objects

model the real world

entities

entities

,

nouns

nouns

in business problem

Also known as

Data Model, business object

model

Example

User Account,

Account,

Order,

Order,

Product,

Product,

Inventory

Inventory

(45)

What are Business Services?

Business Services

Model the verbs

verbs

in

application

Business processes

are the services

services

in the

use cases

Example

Browse

Browse

Catalog

Add

Add

item to Cart

(46)

servlet Catalog Controller Shopping Inventory Order Account JSP Mailer JSP Entity

Entity EJBsEJBs Session

Session EJBsEJBs

Products Items Java Bean Orders Accounts Controller Controller Java Bean Domain Objects Business Services Presentation Layout

Sample Application Architecture Vertical Layering

Presentation Control

View

(47)

Summary

• We went over:

– Advantages of horizontal layershorizontal layers

– Advantages of Vertical TiersVertical Tiers

– Affect of LayersAffect of Layers and Tiers Tiers on Capabilitieson Capabilities..

– the process of architectingprocess of architecting the sample application

References

Related documents

Requests from email, how do i create a read receipt gmail read receipts are you request a long way to work well as you can we promise. Chock full inbox and stay on required exception

(I) Ability to establish and maintain effective working relationships with Utilities personnel, General Services personnel, Parks and Recreation personnel, Golf Course personnel,

The process flow diagram for the preparation of lauha bhasma is available [ 4 ], and the prepa- ration involves samanya sodhana (general purification step), vishesha sodhana

A BPTRS is derived using the method of stationary phase and a frequency domain focusing algorithm is implemented to focus the data of stationary receiver experiments and

The aim of the programme is to provide the Registered General Nurse with the opportunity to develop the specialist knowledge, skills and competence required to deliver safe

This article aims to review the theoretical assumptions of the phenomenon of retranslation, and to test some of these assumptions by studying the data collected from three

If an ANS deficit contributes to risk for poor long-term mathematics achievement, then children in the at-risk group should score significantly lower on the ANS task than children

An alternative transfer model is presented in Chart 13, where the change in the year-on-year rate of the CPI excluding unprocessed food and energy depends on the output gap,