Escolar Documentos
Profissional Documentos
Cultura Documentos
·
ü
A
¦
o
½
¦
JNDI
Wrapper for many naming services
± CORBA, RMI, etc.
¦
CORBA: Complex Programming Model
± Different API for each Service
± Explicit use of service APIs
± Lifecycle depends on services used
Fairly Portable
± Many Languages, many platforms (pro and con)
± Non-Uniform support of Services
|
Transport
± EJB uses RMI interface, RMI uses IIOP
CORBA 3.0 promises object compatibility
with EJB
± Not quite sure what that means
Some EJB Servers contain an ORB
± All EJB Objects are also CORBA objects
||
|G
p
|·
|ü
[
Learning curve
cost of products
cost of extra servers to achieve
performance
time + cost of maintenance
Object-relational mapping
]
2
creates JAR with:
± Remote interface with business functions
± Home for accessing instances of bean
± Bean itself
± Properties and descriptor
integrates beans into clients
modifies and deploys beans
± Organization-specifics, ie security
|o
|
Think of the container as the server, holding
your objects
Containers host enterprise beans
Containers isolate beans from clients
± Intercept client requests
± Set up transactions, security, persistence, etc.
before and after calling EJB methods
± Beans can also call methods of the container
interface to get services
Containers provide JNDI services too
|
G
00
Home Interface
± Extends javax.ejb.EJBHome
± Provides remote access to create, find, remove beans
Remote Interface
± Extends javax.ejb.EJBObject
± Provides remote access to business methods
Bean Class
± Extends a javax.ejb.EnterpriseBean type
± Implements business logic and other functionality
G|
Naming Service
Server
G·
p !
Gü
0
G
U0
!
"
G
U0
·
0
Written by developer
Defines methods accessible by client
± our business methods go here
extends javax.ejb.EJBObject
± standard methods provided by all EJBs
± getEJBHome(), getPrimaryKey(), getHandle(),
remove(), isIdentical(EJBObject obj)
·|
0
"
Developer writes Remote Interface
Tool uses RI to automatically generate the
EJBObject class
Developer writes the EJB source file
N.B.: The EJB does implement the Remote
Interface
± However, you still must implement all the business
methods
± Lame-o-rama: no type safety provided by compiler
± Better: if EJB tool auto-created a new interface for the
EJBObject (oh well)
·G
0
÷
÷
a
a
a
a
a
·ü
]
Container-Managed Persistence
± Server reads values from your bean
± Server stores/loads data for you
± Very easy to write - just define data and server
magically takes care of persistence
·A
½
½
Persistence is automatic
± inserts, updates, and deletes are automatic
± transactions managed automatically
± server reads/writes your bean instance variables
± Server also informs you before/after it's done
something
you implement callback methods
·o
½
½
Easier to write beans
± Focus on business logic, not persistence
± But, requires sophisticated, vendor-specific data
mapping tools
Components more portable
± not backend-specific
± shrink-wrapped components
·
½
Bean-Managed Persistence
± ou code access database directly
± Callback methods dictate when to insert, update,
delete
More control over persistence, performance
Much harder to write
Don¶t need sophisticated data mapping
tools
·
Model entities in a system
± represent their data and associated behavior
one or many relational database tables
an object in an object database
an entity in a legacy system
± Nouns: People, Places or Things
Customer, Employee, Student
City, Building, Hotel Room
Order, Organization, Health Benefit
ü
¦
Not persistent, but can access database
Model tasks, process or agents
± Charge a credit card
± Process a stock purchase
± Perform hotel reservations
Manage interactions of other beans
ü|
¦¦
Perform transitive tasks
Independent business methods
± Act on method arguments, not bean state
± Similar to procedures in traditional TPM systems
Most performant bean type
Not dedicated to one client
üG
¦ ¦
Act on behalf of one client
± Extension of the client
± Agent that performs work for the client
Interdependent business methods
± Bean has conversational state
± Method depend on conversational state
Dedicated to exactly one client
ü·
[
]
Î [
[
Describe bean(s) to the container
± interfaces and class
± type of bean (entity or session)
± identify primary key & container-managed fields
Declare runtime behavior
± transaction attributes of methods
± authorization access to method
± persistence type (BMP vs. CMP)
Written in XML
ü
]
Enterprise beans
J2EE Application Components
Java Applications
Java Applets
Servlets
JSP
üo
#
$
!
ü
½
New with EJB 2.0
Use JMS for asynchronous message queue
services
Allows asynchronous response
± I will gladly pay you Tuesday for a hamburger
today
± Get some of the missing Thread functionality back
Not completely supported yet
± Must sit on a message queue product
ü
± "
Fact:
± EJBs are RMI remote objects
Problem:
± Calling each setter or getter goes across the network
± Slow if you're accessing more than one value at once
Solution:
± Value object which mimics the EJB, only it isn't remote
± EJB has methods to get and set value object
± Client sets/gets values locally, sends/receives
jGuru EJB FAQ
± http://www.jguru.com/faq/EJB
Sun EJB Page
± http://java.sun.com/products/EJB
EJBNow
± http://www.ejbnow.com/
|
%
Richard Monson-Haefel
Dave Orchard
Random Walk Computing
G