SlideShare a Scribd company logo
EJB
Enterprise Java Bean
โ€ข EJB (Enterprise Java Bean) is used to develop
scalable, robust and secured enterprise
applications in java.
โ€ข Unlike RMI, middleware services such as security,
transaction management etc. are provided by EJB
Container to all EJB applications.
โ€ข The current version of EJB is EJB 3.2. The
development of EJB 3 is faster than EJB 2 because
of simplicity and annotations such as @EJB,
@Stateless, @Stateful, @ModelDriven,
@PreDestroy, @PostConstruct etc.
What is EJB
โ€ข EJB is an acronym for enterprise java bean. It
is a specification provided by Sun
Microsystems to develop secured, robust and
scalable distributed applications.
โ€ข To get information about distributed
applications, visit RMI Tutorial first.
โ€ข To run EJB application, you need
an application server (EJB Container) such as
Jboss, Glassfish, Weblogic, Websphere etc.
What is EJB
โ€ข It performs:
โ€ข life cycle management,
โ€ข security,
โ€ข transaction management, and
โ€ข object pooling.
โ€ข EJB application is deployed on the server, so it is
called server side component also.
โ€ข EJB is like COM (Component Object Model)
provided by Microsoft. But, it is different from
Java Bean, RMI and Web Services.
When use Enterprise Java Bean?
โ€ข Application needs Remote Access. In other
words, it is distributed.
โ€ข Application needs to be scalable. EJB
applications supports load balancing,
clustering and fail-over.
โ€ข Application needs encapsulated business
logic. EJB application is separated from
presentation and persistent layer.
Types of Enterprise Java Bean
โ€ข There are 3 types of enterprise bean in java.
โ€ข Session Bean
โ€ข Session bean contains business logic that can be
invoked by local, remote or webservice client.
โ€ข Message Driven Bean
โ€ข Like Session Bean, it contains the business logic but it is
invoked by passing message.
โ€ข Entity Bean
โ€ข It encapsulates the state that can be persisted in the
database. It is deprecated. Now, it is replaced with JPA
(Java Persistent API).
Difference between RMI and EJB
RMI EJB
In RMI, middleware services
such as security, transaction
management, object pooling
etc. need to be done by the
java programmer.
In EJB, middleware services are
provided by EJB Container
automatically.
RMI is not a server-side
component. It is not required to
be deployed on the server.
EJB is a server-side component,
it is required to be deployed on
the server.
RMI is built on the top of socket
programming.
EJB technology is built on the
top of RMI.
EJB and Webservice
โ€ข In EJB, bean component and bean client both
must be written in java language.
โ€ข If bean client need to be written in other
language such as .net, php etc, we need to go
with webservices (SOAP or REST). So EJB with
web service will be better option.
Disadvantages of EJB
โ€ข Requires application server
โ€ข Requires only java client. For other language
client, you need to go for webservice.
โ€ข Complex to understand and develop ejb
applications.
Session Bean
โ€ข Session bean encapsulates business logic only,
it can be invoked by local, remote and
webservice client.
โ€ข It can be used for calculations, database
access etc.
โ€ข The life cycle of session bean is maintained by
the application server (EJB Container).
Types of Session Bean
โ€ข There are 3 types of session bean.
โ€ข 1) Stateless Session Bean: It doesn't maintain
state of a client between multiple method
calls.
โ€ข 2) Stateful Session Bean: It maintains state of
a client across multiple requests.
โ€ข 3) Singleton Session Bean: One instance per
application, it is shared between clients and
supports concurrent access.
Stateless Session Bean
โ€ข Stateless Session bean is a business object that
represents business logic only. It doesn't have
state (data).
โ€ข In other words, conversational state between
multiple method calls is not maintained by the
container in case of stateless session bean.
โ€ข The stateless bean objects are pooled by the EJB
container to service the request on demand.
โ€ข It can be accessed by one client at a time. In case
of concurrent access, EJB container routes each
request to different instance.
Annotations used in Stateless Session
Bean
โ€ข There are 3 important annotations used in
stateless session bean:
โ€ข @Stateless
โ€ข @PostConstruct
โ€ข @PreDestroy
Life cycle of Stateless Session Bean
โ€ข There is only two states of stateless session bean: does not
exist and ready. It is explained by the figure given below.
Life cycle of Stateless Session Bean
EJB Container creates and maintains a pool of
session bean first. It injects the dependency if
then calls the @PostConstruct method if any.
Now actual business logic method is invoked by
the client. Then, container calls @PreDestory
method if any. Now bean is ready for garbage
collection.
Stateful Session Bean
โ€ข Stateful Session bean is a business object that
represents business logic like stateless session
bean. But, it maintains state (data).
โ€ข In other words, conversational state between
multiple method calls is maintained by the
container in stateful session bean.
Annotations used in Stateful Session
Bean
There are 5 important annotations used in
stateful session bean:
โ€ข @Stateful
โ€ข @PostConstruct
โ€ข @PreDestroy
โ€ข @PrePassivate
โ€ข @PostActivate
JMS
โ€ข JMS (Java Message Service) is an API that
provides the facility to create, send and read
messages. It provides loosely coupled, reliable
and asynchronous communication.
โ€ข JMS is also known as a messaging service.
Understanding Messaging
โ€ข Messaging is a technique to communicate
applications or software components.
โ€ข JMS is mainly used to send and receive
message from one application to another.
Requirement of JMS
โ€ข Generally, user sends message to application.
But, if we want to send message from one
application to another, we need to use JMS
API.
โ€ข Consider a scenario, one application A is
running in INDIA and another application B is
running in USA. To send message from A
application to B, we need to use JMS.
Advantage of JMS
โ€ข 1) Asynchronous: To receive the message,
client is not required to send request.
Message will arrive automatically to the client.
โ€ข 2) Reliable: It provides assurance that
message is delivered.
Messaging Domains
โ€ข There are two types of messaging domains in
JMS.
โ€ข Point-to-Point Messaging Domain
โ€ข Publisher/Subscriber Messaging Domain
Point-to-Point (PTP) Messaging
Domain
โ€ข In PTP model, one message is delivered to
one receiver only. Here, Queue is used as a
message oriented middleware (MOM).
โ€ข The Queue is responsible to hold the message
until receiver is ready.
โ€ข In PTP model, there is no timing
dependency between sender and receiver.
enterprise java bean
Publisher/Subscriber (Pub/Sub)
Messaging Domain
โ€ข In Pub/Sub model, one message is delivered
to all the subscribers. It is like broadcasting.
Here, Topic is used as a message oriented
middleware that is responsible to hold and
deliver messages.
โ€ข In PTP model, there is timing
dependency between publisher and
subscriber.
enterprise java bean
JMS Programming Model
Message Driven Bean
A message driven bean (MDB) is a bean that contains business
logic. But, it is invoked by passing the message. So, it is like
JMS Receiver.
MDB asynchronously receives the message and processes it.
A message driven bean receives message from queue or topic,
so you must have the knowledge of JMS API.
A message driven bean is like stateless session bean that
encapsulates the business logic and doesn't maintain state.
enterprise java bean
Entity Bean in EJB 3.x
โ€ข Entity bean represents the persistent data stored in the
database. It is a server-side component.
โ€ข In EJB 2.x, there was two types of entity beans: bean
managed persistence (BMP) and container managed
persistence (CMP).
โ€ข Since EJB 3.x, it is deprecated and replaced by JPA (Java
Persistence API) that is covered in the hibernate
tutorial.
โ€ข In hibernate tutorial, there are given hibernate with
annotation examples where we are using JPA
annotations. The JPA with Hibernate is widely used
today.
enterprise java bean
Ad

More Related Content

What's hot (20)

Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
Armen Arzumanyan
ย 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
Hitesh Parmar
ย 
EJB 2
EJB 2EJB 2
EJB 2
Khushboo Shaukat
ย 
Session bean
Session beanSession bean
Session bean
sandeep54552
ย 
Hive(ppt)
Hive(ppt)Hive(ppt)
Hive(ppt)
Abhinav Tyagi
ย 
Java Beans
Java BeansJava Beans
Java Beans
Ankit Desai
ย 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
chakrapani tripathi
ย 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
OECLIB Odisha Electronics Control Library
ย 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
sandeep54552
ย 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization
Hafiz faiz
ย 
Asp Architecture
Asp ArchitectureAsp Architecture
Asp Architecture
Om Vikram Thapa
ย 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
ย 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
ย 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
ย 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
ย 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
Vikas Jagtap
ย 
JDBC โ€“ Java Database Connectivity
JDBC โ€“ Java Database ConnectivityJDBC โ€“ Java Database Connectivity
JDBC โ€“ Java Database Connectivity
Information Technology
ย 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
ย 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
ย 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
ย 
Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
Armen Arzumanyan
ย 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
Hitesh Parmar
ย 
Session bean
Session beanSession bean
Session bean
sandeep54552
ย 
Java Beans
Java BeansJava Beans
Java Beans
Ankit Desai
ย 
Query Decomposition and data localization
Query Decomposition and data localization Query Decomposition and data localization
Query Decomposition and data localization
Hafiz faiz
ย 
Asp Architecture
Asp ArchitectureAsp Architecture
Asp Architecture
Om Vikram Thapa
ย 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
ย 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
ย 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
ย 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
ย 
JDBC โ€“ Java Database Connectivity
JDBC โ€“ Java Database ConnectivityJDBC โ€“ Java Database Connectivity
JDBC โ€“ Java Database Connectivity
Information Technology
ย 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
ย 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
ย 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
ย 

Similar to enterprise java bean (20)

Unite5-EJB-2019.ppt
Unite5-EJB-2019.pptUnite5-EJB-2019.ppt
Unite5-EJB-2019.ppt
Krishna900061
ย 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
Tharindu Weerasinghe
ย 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another Introduction
Kelum Senanayake
ย 
Ch4 ejb
Ch4 ejbCh4 ejb
Ch4 ejb
Raghavendra Goud
ย 
EJB.docx
EJB.docxEJB.docx
EJB.docx
VeningstonK1
ย 
Java j2eeTutorial
Java j2eeTutorialJava j2eeTutorial
Java j2eeTutorial
QUONTRASOLUTIONS
ย 
J2 ee container & components
J2 ee container & componentsJ2 ee container & components
J2 ee container & components
Keshab Nath
ย 
Connecting ejb with mule
Connecting ejb with muleConnecting ejb with mule
Connecting ejb with mule
Ruman Khan
ย 
UNIT 4.pptx
UNIT 4.pptxUNIT 4.pptx
UNIT 4.pptx
OmkarKamble76
ย 
Ejb notes
Ejb notesEjb notes
Ejb notes
Mumbai Academisc
ย 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questions
guest346cb1
ย 
J2 ee tutorial ejb
J2 ee tutorial ejbJ2 ee tutorial ejb
J2 ee tutorial ejb
Niraj Bharambe
ย 
EJB3 Basics
EJB3 BasicsEJB3 Basics
EJB3 Basics
Emprovise
ย 
Aravind vinnakota ejb_architecture
Aravind vinnakota ejb_architectureAravind vinnakota ejb_architecture
Aravind vinnakota ejb_architecture
tayab4687
ย 
Session 2 Tp2
Session 2 Tp2Session 2 Tp2
Session 2 Tp2
phanleson
ย 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
Simon Ritter
ย 
Java bean
Java beanJava bean
Java bean
Jafar Nesargi
ย 
Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...
Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...
Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...
SSA KPI
ย 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
achraf_ing
ย 
EJB 3.0 and J2EE
EJB 3.0 and J2EEEJB 3.0 and J2EE
EJB 3.0 and J2EE
Aniruddha Ray (Ani)
ย 
Unite5-EJB-2019.ppt
Unite5-EJB-2019.pptUnite5-EJB-2019.ppt
Unite5-EJB-2019.ppt
Krishna900061
ย 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another Introduction
Kelum Senanayake
ย 
Java j2eeTutorial
Java j2eeTutorialJava j2eeTutorial
Java j2eeTutorial
QUONTRASOLUTIONS
ย 
J2 ee container & components
J2 ee container & componentsJ2 ee container & components
J2 ee container & components
Keshab Nath
ย 
Connecting ejb with mule
Connecting ejb with muleConnecting ejb with mule
Connecting ejb with mule
Ruman Khan
ย 
UNIT 4.pptx
UNIT 4.pptxUNIT 4.pptx
UNIT 4.pptx
OmkarKamble76
ย 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questions
guest346cb1
ย 
J2 ee tutorial ejb
J2 ee tutorial ejbJ2 ee tutorial ejb
J2 ee tutorial ejb
Niraj Bharambe
ย 
EJB3 Basics
EJB3 BasicsEJB3 Basics
EJB3 Basics
Emprovise
ย 
Aravind vinnakota ejb_architecture
Aravind vinnakota ejb_architectureAravind vinnakota ejb_architecture
Aravind vinnakota ejb_architecture
tayab4687
ย 
Session 2 Tp2
Session 2 Tp2Session 2 Tp2
Session 2 Tp2
phanleson
ย 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
Simon Ritter
ย 
Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...
Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...
Java Platform and IDE Netbeans 6.7 for Developing Enterprise and Web Applicat...
SSA KPI
ย 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
achraf_ing
ย 
Ad

Recently uploaded (20)

UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
ย 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
ย 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
ย 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
ย 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
ย 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
ย 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
ย 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
ย 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
ย 
Ad

enterprise java bean

  • 1. EJB
  • 2. Enterprise Java Bean โ€ข EJB (Enterprise Java Bean) is used to develop scalable, robust and secured enterprise applications in java. โ€ข Unlike RMI, middleware services such as security, transaction management etc. are provided by EJB Container to all EJB applications. โ€ข The current version of EJB is EJB 3.2. The development of EJB 3 is faster than EJB 2 because of simplicity and annotations such as @EJB, @Stateless, @Stateful, @ModelDriven, @PreDestroy, @PostConstruct etc.
  • 3. What is EJB โ€ข EJB is an acronym for enterprise java bean. It is a specification provided by Sun Microsystems to develop secured, robust and scalable distributed applications. โ€ข To get information about distributed applications, visit RMI Tutorial first. โ€ข To run EJB application, you need an application server (EJB Container) such as Jboss, Glassfish, Weblogic, Websphere etc.
  • 4. What is EJB โ€ข It performs: โ€ข life cycle management, โ€ข security, โ€ข transaction management, and โ€ข object pooling. โ€ข EJB application is deployed on the server, so it is called server side component also. โ€ข EJB is like COM (Component Object Model) provided by Microsoft. But, it is different from Java Bean, RMI and Web Services.
  • 5. When use Enterprise Java Bean? โ€ข Application needs Remote Access. In other words, it is distributed. โ€ข Application needs to be scalable. EJB applications supports load balancing, clustering and fail-over. โ€ข Application needs encapsulated business logic. EJB application is separated from presentation and persistent layer.
  • 6. Types of Enterprise Java Bean โ€ข There are 3 types of enterprise bean in java. โ€ข Session Bean โ€ข Session bean contains business logic that can be invoked by local, remote or webservice client. โ€ข Message Driven Bean โ€ข Like Session Bean, it contains the business logic but it is invoked by passing message. โ€ข Entity Bean โ€ข It encapsulates the state that can be persisted in the database. It is deprecated. Now, it is replaced with JPA (Java Persistent API).
  • 7. Difference between RMI and EJB RMI EJB In RMI, middleware services such as security, transaction management, object pooling etc. need to be done by the java programmer. In EJB, middleware services are provided by EJB Container automatically. RMI is not a server-side component. It is not required to be deployed on the server. EJB is a server-side component, it is required to be deployed on the server. RMI is built on the top of socket programming. EJB technology is built on the top of RMI.
  • 8. EJB and Webservice โ€ข In EJB, bean component and bean client both must be written in java language. โ€ข If bean client need to be written in other language such as .net, php etc, we need to go with webservices (SOAP or REST). So EJB with web service will be better option.
  • 9. Disadvantages of EJB โ€ข Requires application server โ€ข Requires only java client. For other language client, you need to go for webservice. โ€ข Complex to understand and develop ejb applications.
  • 10. Session Bean โ€ข Session bean encapsulates business logic only, it can be invoked by local, remote and webservice client. โ€ข It can be used for calculations, database access etc. โ€ข The life cycle of session bean is maintained by the application server (EJB Container).
  • 11. Types of Session Bean โ€ข There are 3 types of session bean. โ€ข 1) Stateless Session Bean: It doesn't maintain state of a client between multiple method calls. โ€ข 2) Stateful Session Bean: It maintains state of a client across multiple requests. โ€ข 3) Singleton Session Bean: One instance per application, it is shared between clients and supports concurrent access.
  • 12. Stateless Session Bean โ€ข Stateless Session bean is a business object that represents business logic only. It doesn't have state (data). โ€ข In other words, conversational state between multiple method calls is not maintained by the container in case of stateless session bean. โ€ข The stateless bean objects are pooled by the EJB container to service the request on demand. โ€ข It can be accessed by one client at a time. In case of concurrent access, EJB container routes each request to different instance.
  • 13. Annotations used in Stateless Session Bean โ€ข There are 3 important annotations used in stateless session bean: โ€ข @Stateless โ€ข @PostConstruct โ€ข @PreDestroy
  • 14. Life cycle of Stateless Session Bean โ€ข There is only two states of stateless session bean: does not exist and ready. It is explained by the figure given below.
  • 15. Life cycle of Stateless Session Bean EJB Container creates and maintains a pool of session bean first. It injects the dependency if then calls the @PostConstruct method if any. Now actual business logic method is invoked by the client. Then, container calls @PreDestory method if any. Now bean is ready for garbage collection.
  • 16. Stateful Session Bean โ€ข Stateful Session bean is a business object that represents business logic like stateless session bean. But, it maintains state (data). โ€ข In other words, conversational state between multiple method calls is maintained by the container in stateful session bean.
  • 17. Annotations used in Stateful Session Bean There are 5 important annotations used in stateful session bean: โ€ข @Stateful โ€ข @PostConstruct โ€ข @PreDestroy โ€ข @PrePassivate โ€ข @PostActivate
  • 18. JMS โ€ข JMS (Java Message Service) is an API that provides the facility to create, send and read messages. It provides loosely coupled, reliable and asynchronous communication. โ€ข JMS is also known as a messaging service.
  • 19. Understanding Messaging โ€ข Messaging is a technique to communicate applications or software components. โ€ข JMS is mainly used to send and receive message from one application to another.
  • 20. Requirement of JMS โ€ข Generally, user sends message to application. But, if we want to send message from one application to another, we need to use JMS API. โ€ข Consider a scenario, one application A is running in INDIA and another application B is running in USA. To send message from A application to B, we need to use JMS.
  • 21. Advantage of JMS โ€ข 1) Asynchronous: To receive the message, client is not required to send request. Message will arrive automatically to the client. โ€ข 2) Reliable: It provides assurance that message is delivered.
  • 22. Messaging Domains โ€ข There are two types of messaging domains in JMS. โ€ข Point-to-Point Messaging Domain โ€ข Publisher/Subscriber Messaging Domain
  • 23. Point-to-Point (PTP) Messaging Domain โ€ข In PTP model, one message is delivered to one receiver only. Here, Queue is used as a message oriented middleware (MOM). โ€ข The Queue is responsible to hold the message until receiver is ready. โ€ข In PTP model, there is no timing dependency between sender and receiver.
  • 25. Publisher/Subscriber (Pub/Sub) Messaging Domain โ€ข In Pub/Sub model, one message is delivered to all the subscribers. It is like broadcasting. Here, Topic is used as a message oriented middleware that is responsible to hold and deliver messages. โ€ข In PTP model, there is timing dependency between publisher and subscriber.
  • 28. Message Driven Bean A message driven bean (MDB) is a bean that contains business logic. But, it is invoked by passing the message. So, it is like JMS Receiver. MDB asynchronously receives the message and processes it. A message driven bean receives message from queue or topic, so you must have the knowledge of JMS API. A message driven bean is like stateless session bean that encapsulates the business logic and doesn't maintain state.
  • 30. Entity Bean in EJB 3.x โ€ข Entity bean represents the persistent data stored in the database. It is a server-side component. โ€ข In EJB 2.x, there was two types of entity beans: bean managed persistence (BMP) and container managed persistence (CMP). โ€ข Since EJB 3.x, it is deprecated and replaced by JPA (Java Persistence API) that is covered in the hibernate tutorial. โ€ข In hibernate tutorial, there are given hibernate with annotation examples where we are using JPA annotations. The JPA with Hibernate is widely used today.