Java Enterprise Services

drivercutInternet and Web Development

Nov 13, 2013 (3 years and 9 months ago)

89 views

Component-Based Software Engineering
ECE493-Topic 4
Winter 2006
Lecture 16–Java Enterprise
(Part A)
Ladan Tahvildari
Ladan Tahvildari
Assistant Professor
Assistant Professor
Dept. of Elect. & Comp. Eng.
Dept. of Elect. & Comp. Eng.
University of Waterloo
University of Waterloo
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
2
2
Abstract views
(PIM,
Written in UML)
Domain-specific
Models
(PSM,
Written in UML with
extra notation)
Implementations
From Abstractions to Implementations
Abstract system
architecture
Enterprise
Middleware
Architecture
OO:
simple
Java:
EJB,
JMS, JSP
.NET:
COM+,
ASP
Safety Critical
Architecture
C
Embedded
System
Architecture
CORBA
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
3
3
Java Enterprise Services

Sun Microsystems provides specifications for a
comprehensive suite of technologies to solve large
scale distributed system problems

This suite is the Java 2 Enterprise Edition,
commonly known as J2EEwhich offers a suite of
software specification to:
–Design, develop, assemble and deploy enterprise
applications

Discuss the architecture of J2EE and how it can be
usedtodevelopdistributedmulti
-
tiered
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
4
4
J2EE Technology Architecture
Server
platform
JTS
JMAPI
JNDI
JMS
JDBC
JAXP
JAAS

Enterprise Java Beans Components
Java Server
pages
Servlets
Application clients
Web clients
IIOP,
others
html
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
5
5
J2EE Suite

XML Technology
–The Java API for XML Processing (JAXP)
–The Java API for XML-based RPC (JAX-RPC)
–SOAP with Attachments API for Java (JAAS)
–The Java API for XML Registries (JAXR)

Web Technology
–Java Servlets
–JavaServerPages (JSP)

Enterprise Java Bean (EJB) Technology
–Session beans
–Entity beans
–Message-driven beans

Platform Services
–Transactions
–Java Message Service
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
6
6
J2EE-Based Application

The J2EE APIs enable distributed systems and applications
through the following:
–Unified application model across tiers with enterprise beans
–Simplified response and request mechanism with JSP pages and servlets
–Reliable security model with JAAS
–XML-based data interchange integration with JAXP
–Simplified interoperability with the J2EE Connector Architecture
–Easy database connectivity with the JDBC API
–Enterprise application integration with message-driven beans and JMS,
JTA, and JNDI
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
7
7
Enterprise Application Model
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
8
8
Distributed Multi-tiered Applications

Services, clients (people and application) and data are
distributed geographically across many platforms and
many machines.

Multiple tiers:
–Client-tier (browser or client-application)
–Web-tier (web-server: Java Server Pages)
–Business-tier(logic; Examples: Enterprise Java Beans)
–Enterprise-Information-System (EIS) tier (database)
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
9
9
J2EE Clients

Web Clients
–Dynamic web pages with HTML, rendered by web browsers
–Can include applets
–Communicates with server typically using HTTP

Application Clients
–User interface using GUI components such as Swing
–Directly accesses the business logic tier
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
10
10
Web-tier Components

Client can communicate with the business tier either directly
or through servletsof JSP that are located in the web-tier

Web-tier can help in pre-processingand allows distribution
of the functionality

Servletsare special classes to realize the request-response
model(get, post of HTTP)

JSP is a developer-friendly wrapper over the servlet classes
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
11
11
Business-tier Components

This is defined by the logic that pertains to the (business)
application that is being developed

Enterprise Java Beans (EJB) can be used to implement this
tier

This tier receives the data from the web-tier and processes
the data and sends it to the EIS-tier and takes the data from
the EIS and sends it to the web-tier
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
12
12
Enterprise Information System Tier

In general this corresponds to thedatabase (relational
database) and other information management system

The other information management systems may include
Enterprise Resource Planning (ERP) and legacy system
connected through open database connectivity
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
13
13
Enterprise Java Beans

Enterprise Java Beans ( EJB ) is
–amiddleware component modelfor Java
–aspecificationfor creating server-side, scalable,
transactional, multi-userand secure enterprise-level
applications

Presented by Sun in the 1999, they are easier than other
technologies as RMI or CORBA
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
14
14
Application Server -Architecture
Presentation
•HTML Application
•Java Application Business Logic
Data Access
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
15
15
J2EE Application Server

Java 2 Enterprise Edition standardizes interfaces for
Application Server components
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
16
16
Java versus .NET for the Enterprise
Activation/Passivate (on statefulbeans)JIT Activation
Java Server Page (JSP) ASP.NET
Instance PoolingObject Pooling
Can be implemented through JMSQueued Components
Java Message Service (JMS)Loosely Coupled Events
Java Transaction Service (JTS)Transactions
EJB
Session Beans (Stateless, Stateful)
Entity Beans
Message-Driven Beans
COM+ Components
Java.NET
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
17
17
EJB Overview
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
18
18
Types of Enterprise Java Beans
•Session Beans
Stateful
Stateless
•Entity Beans
Bean-Managed Persistence (BMP)
Container-Managed Persistence (CMP)
Enterprise Java Beans Query Language
•Message-Driven Beans
Session bean with Java Messaging features
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
19
19
Session Beans

For transient functions

Represents “conversational”state

Typically one per request

Data is non-persistent

Lifetime is limited by the client’s
–once the client exits, the session bean and data are gone

Simple and easy to program

Light-weight
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
20
20
Stateful Session Bean’s Life Cycle

The client invoke the create method

The EJB container :
–Instantiates the bean
–Invokes the setSessionContext
–Invokes ejbCreate

The bean is ready,. While in the ready state
–EJB container may passivatethe bean moving it from memory to
secondary storage
–Aclient may invoke a business method
–EJB container may activate abean,moving it back to the ready
stage, and then calls the bean's ejbActivate method
–A client may invoke the remove method and the container calls the
bean's ejbRemove method
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
21
21
Stateful Session Bean’s Life
Cycle
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
22
22
Stateless Session Bean’s Life
Cycle

The client invoke the create method

The EJB container :
–Instantiates the bean
–Invokes the setSessionContext
–Invokes ejbCreate

The bean is ready. While in the ready state
–Aclient may invoke a business method
–A client may invoke the remove method and the container calls the
bean's ejbRemove method
–It’s never passivate
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
23
23
Stateless Session Bean’s Life
Cycle
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
24
24
Types of Enterprise Java Beans
•Session Beans
Stateful
Stateless
•Entity Beans
Bean-Managed Persistence (BMP)
Container-Managed Persistence (CMP)
Enterprise Java Beans Query Language
•Message-Driven Beans
Session bean with Java Messaging features
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
25
25
Entity Bean

“Transactional”in behavior

Can be shared among clients

Persistent:data exists permanently after client quits

Corresponds to a row of a relational database

The persistence (storing into the database) can be done:
–automatically by the “container”(CMP)or
–explicitly by the bean (BMP)

In BMP, you write the code for database access calls
–This may be additional responsibility but it gives control to the
bean developer.
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
26
26
Entity Bean’s Life Cycle

The EJB container:
–Creates the instance
–Calls the setEntityContext

The entity bean moves to a pool of available instances

While in the pool:
–Instance is not associated with any particular object identity
–All instances in the pool are identical
–EJB containermayassign an identity to an instance when moving it to the ready
stage invokingthe ejbActivate method
–Aclient may invoke the create method
•EJB container callsejbCreate and ejbPostCreate
–EJB container may remove the instance invoking unsetEntityContext

While in the ready state:
–A client may invoke entity bean's business methods
–A client may invoke the remove method
•EJB container callsthe ejbRemove method
–EJB container may invoke the ejbPassivate method
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
27
27
Entity Bean’s Life Cycle
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
28
28
Types of Enterprise Java Beans
•Session Beans
Stateful
Stateless
•Entity Beans
Bean-Managed Persistence (BMP)
Container-Managed Persistence (CMP)
Enterprise Java Beans Query Language
•Message-Driven Beans
Session bean with Java Messaging features
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
29
29
Message-Driven Bean

A message driven bean is an enterprise bean that
allows J2EE applications to process messages
asynchronously

It acts as a JMS listener, which is similar to an event
listener except that it receives messages instead of
events.

The messages can be sent by any J2EE component:
–an application client
–another enterprise bean
–a web component
–a non-J2EE system using JMS

Retain no data or conversational state
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
30
30
Message Driven Bean’s Life Cycle

EJB container creates a pool of message-driven bean
instances

For each instance, the EJB container instantiates the bean :
–It calls the setMessageDrivenContext
–It calls the instance's ejbCreate

Like a stateless session bean,it’s never passivated, It has
only two states:
–Nonexistent
–Ready to receive messages

While in the ready state :
–EJB container may call onMessage
–EJB container may call the ejbRemove
February 28, 2006
February 28, 2006
ECE493
ECE493
-
-
T4
T4
31
31
Message Driven Bean’s Life
Cycle