Title: J2EE application architecture Java 2 Platform Enterprise Edition
1J2EE application architecture (Java 2
Platform Enterprise Edition)
A standard architecture specifically oriented to
the development and deployment of enterprise
web-oriented applications using Java.
2J2EE application architecture Web-based
applications
Web server
EJB server
EJB container
Web container
RMI
Web application
enterprise bean
DB
client
internet
Web-EJB container
EJB container
local invocation
enterprise bean
Web application
3J2EE application architecture three-tier
applications
advantages
simplicity application portability component
reusability separation of business logic from
representation logic easy development of Web
services
4Enterprise JavaBeans (EJB)
Managed server-side components for the modular
construction of enterprise applications.
5Remote Method Invocation (RMI) loop
Client Network Middle tier
skeleton
server object
stub
5) return result
6EJB types
- entity
- session
- message-driven.
7EJB object and EJB home (for entity and session
beans)
EJB server
Client
EJB container
8Primary services
- concurrency
- transaction
- timer
- persistence
- asynchronous messaging
- object distribution
- naming
- security.
9Instance pooling entity bean life cycle
no state
pooled state
ready state
10Instance pooling
client application
EJB server
pooled state
11Instance pooling
client application
EJB server
EJB object
bean instance in ready state
pooled state
12Java Naming and Directory Interface (JNDI)
JNDI is a standard Java package that provides a
uniform API for accessing a wide range of
services.
13Java RMI-IIOP return types and parameters
- Return types and parameters
- declared (checked by the compiler)
- actual (checked at runtime).
- primitives (byte, boolean, char, )
- Java serializable types (java.io.Serializable)
- Java RMI remote types (java.rmi.Remote).
14Java RMI-IIOP return types and parameters
remote reference
client
original serializable object
EJB object
after a serializable object is passed, copies
reside on both the client and the bean instance.
Changes to one copy are not reflected in the
other.
bean instance
15Java RMI-IIOP return types and parameters
client application
bean instance
EJB object
remote reference
A
B
original remote reference
A
copy of remote reference
EJB object
bean instance
16Java RMI-IIOP narrow
The remote home interface
The remote home interface bean metadata
The remote home interface creating and finding
beans
The remote interface primary key
The remote interface comparing beans for identity
The remote interface the enterprise bean handle
The local interface
The local home interface
Local vs. Remote
17Basic persistence
18Persistence and relationship fields
Customer
String getLastName() void setLastName(String
ln) String getFirstName() void setFirstName(String
fn) AddressLocal getHomeAddress() void
setHomeAddress(AddressLocal addr)
1
1
Address
getStreet() setStreet(String strt) getCity() setCi
ty(String city) getState() setState(String
st) getZip() setZip(String zp)
19Message-driven beans (MDB)
Stateless, server-side, transaction-aware
components for processing asynchronous messages
delivered via JMS.
20Message-driven beans
Java Message Service (JMS)
A vendor neutral API that can be used to access
enterprise messaging systems. Enterprise
messaging systems facilitate the exchange of
messages between software applications over a
network.
21Message-driven beans
JMS message
MSG client
MDBs container
JMS message
method in bean class
Entity container
method reacting to the msg
DB