Sei sulla pagina 1di 21

EJB Technology

A New Trend in Web Technology………

prepared BY : Shiv Sharma

Lecturer IT Dept.
Agenda
 Background
 JavaBeans

 What is EJB?

 Architecture

 Roles

 Steps involved

 Questions?

By: shiv kumar sharma


Background
Monolithic systems
No reuse

Fat clients,
data model reused
Client/server

Thin clients,
both data model and N-Tier
business logic reused

By: shiv kumar sharma


3-tier architecture
Presentation Clients, GUI

Business logic “middleware”

Data DBMSs

By: shiv kumar sharma


JavaBeans vs. EJB
 Can be visible or  Are always
invisible invisible
 Designed to run  Are distributed
locally executable
 Are described with components on a
Properties, server
BeanInfo classes  Are described with
and Customizers a
DeploymentDescri
ptor
By: shiv kumar sharma
The J2EE
 Naming service
– provides a common way of naming
objects and directories

 Transaction handling
– Java Transaction Services (JTS)
 Presentation (JSP, Servlet)
 Communication (RMI)

 Distribution, component model (EJB)

By: shiv kumar sharma


What is Enterprise Java
Beans?
 Defines a standard to build distributed
systems on the server side
 Frees developers from “plumbing”

( transactions , security, pooling etc.)


 Is a framework to create enterprise

middleware

By: shiv kumar sharma


Why EJB
 Independence of middleware (both
regarding hard- and software)
 Automatic transaction handling

 Automatic distribution

 Portability

 Scalability

By: shiv kumar sharma


EJB architecture
client EJB server
EJB container
EJB Home

EJBean
EJB Object

security
JNDI
JTS

…..
By: shiv kumar sharma
Different types of EJBs,
1
 Entity bean
– corresponds to a record in a database
 Session bean
– handles business flow
(one per client)

By: shiv kumar sharma


Different types of EJBs,
2
EJB

Entity Session

Bean managed Container managed stateless stateful

By: shiv kumar sharma


Entity EJBs

 Bean managed persistence (BMP)


– developer writes JDBC code and SQL
statements
 Container managed persistence (CMP)
– Container generates methods to read and
write to the database
– Takes necessary information from the
Deployment Descriptor

By: shiv kumar sharma


Resource handling
 Passivation
– the process that stores the beans state to a
secondary memory, and swaps it out of primary
memory
 Activation
– the opposite process of recreating the bean into
primary memory

This holds for every type of bean except the


stateless session bean
By: shiv kumar sharma
Session EJBs
 are mainly used for business logic
 should constitute the clients only

interface to the system


 controls processes that spans several

entity beans
 lives as long as the client is alive

 will not survive a server crash

 are difficult to reuse

By: shiv kumar sharma


Entity EJBs
 are used as the object model
 contains all JDBC code

 should guarantee the integrity of the

database
 lever as long as the database (“for

ever”)
 should be reused

By: shiv kumar sharma


Automatic database
handling
 Create an entity bean with CMP
 Tell server what database you use
 Specify what attributes should go into what
database fields

-> all being made in the Deployment


Descriptor
This completely cuts the code from the
database model and vendor, and frees the
developer from JDBC coding!

By: shiv kumar sharma


Roles in EJB

 EJB server provider


 EJB container provider

 EJB developer

 EJB deployer

 Client software developer

By: shiv kumar sharma


Steps in creating an EJB,
1
 Write your Home interface
[create(...) and findByXXX(...)]
 Write your Remote interface
[implement your business methods]
 Develop your entity or session bean
 If it is a entity bean define a

PrimaryKey class
 Write your Deployment Descriptor

By: shiv kumar sharma


Steps in creating an EJB,
2
 Compile your files and generate
container code with the server tools
 Set up a data source to your

database
 Install the bean in the server

 Develop the client application

 Start your server and run the client!

By: shiv kumar sharma


Questions ?

By: shiv kumar sharma


Thanks

By: shiv kumar sharma

Potrebbero piacerti anche