SlideShare a Scribd company logo
Enterprise
JavaBeans (EJB)
What are EJBs?
They are components that can be connected to
form a system
They can represent data
They can represent behavior
Usually, EJBs fall into only one of these
categories
They are typically used in the server tier
EJBs can be persisted
EJBs can interact with other EJBs
Advantages of EJBs
EJBs are reusable components
Can be reused in different parts of the system
Can be packaged into libraries and sold
EJBs Can be combined visually using development IDEs
E.g. Visual Age, Visual Café
EJBs provide convenient abstractions so it do not require
you to write:
Multi-threaded, multiple access code
Database access code (e.g. JDBC)
Network communication code (i.e. it uses RMI) for client/server
communication
Network communication code for EJB to EJB communication
Transaction management code
EJBs from different businesses can interact easily
This is because of their well-defined interfaces
EJB in the Big Picture of J2EE
EJB Communication
EJBs use IIOP as the wire protocol
Therefore, EJBs are compatible with RMI (i.e.,
RMI over IIOP) and CORBA libraries
Thus, you could write an EJB client in any
language that supports CORBA
EJB as Client/Server Middleware
Think of EJBs as just another Client/Server
middleware like RMI, CORBA, or Web Services
The EJB instance itself is the server
EJBs have clients (objects that call its methods)
One complication is that EJB clients can be:
Java Applets and Applications (using RMI or CORBA)
Non-Java applications (using CORBA)
JSPs and Servlets (using RMI or CORBA)
Other EJBs (using RMI or CORBA)
EJBs & 3-Tiered Architectures
Applet
Web Page Servlets & JSPs
EJBs
Database
Client Tier Server Tier Database Tier
In enterprise systems, EJB clients are
usually: Servlets, JSPs, or Other EJBs
EJBs & Multi-Tiered Architectures
Applet
Web Page Servlets & JSPs
EJBs
Database
3rd Party
EJBs
How EJBs Change Things
EJBs are most suitable for developing business
logic and data manipulation
If all of the business logic operations and data
manipulations are done using EJBs, the JSPs and
Servlets will be focused mainly on displaying the
results of those operations
Session EJBs: Used to represent system behavior (i.e.
business logic)
e.g. Storing products to purchase in the shopping cart
Entity EJBs: Used to represent & manipulate system data
e.g. Finding products that match a search term
Application Servers
Containers where EJBs (and JSPs and servlets)
are executed
Provide EJB functionality, including:
Persistence through databases (using JDBC)
Transactions (using Java Transaction Service)
Can provide advanced features, including:
Load balancing
Database connection pooling
Here are the major application servers:
SJS AP, WebLogic (BEA), Internet Application
Server or iAS (Oracle), WebSphere (IBM)
Alternatives to EJBs
Web Services are one of the technologies
competing with EJBs
Web services use the SOAP protocol to exchange
information with some server
SOAP uses an XML format to exchange request and
response information via HTTP
Due to SOAP's well-defined protocol, Web Services can be
used to exchange information between businesses (B2B)
Web services provide one or more remote method that
can be accessed easily from other applications
Alternatives to EJBs
CORBA objects provide some functionality similar
to EJBs:
Persistence (of CORBA object data)
Transactions (between CORBA objects)
Security (between CORBA objects)
CORBA and EJBs are closely related, in fact, they
use the same wire protocol:
IIOP
In some sense, EJBs can be considered to be an
enhanced version of CORBA
Except that EJBs can only be created in Java
EJB Types
Types of Enterprise Beans
Session beans:
Also called business process objects
They represent the business logic of the system
Their lifetime is usually an entire session
When a session is done, the session bean expires
i.e. Session bean instances exist as long as a specific
user is using the system
Entity beans:
Also called business data objects
They represent persistent data
Often the data persistence is managed through a
database, using JDBC
Subtypes of Session Beans
Stateful:
Used for operations that require multiple
requests to be completed
Maintain data between requests
Stateless:
Used for operations that can be performed in
a single request
Do not maintain persistent data between
subsequent requests from a given client
Entity Beans Explained
Entity beans represent data in the system
In addition, entity beans are used to search for, modify, create and
delete data
Usually, this data resides in a relational database
Each entity bean typically represents a single row in some database
table
An entity bean instance exists as long as the data is being
used
When the EJB client is done with the instance, the entity bean
instance usually returns to a bean pool
The client for an entity bean is typically a session bean, since
behavior usually involves the manipulation of data
Subtypes of Entity Beans
Bean-managed persistence:
The entity bean handles its own persistence
Often via JDBC (or SQL/J) to a database
The bean author is required to write persistence-
management code into the bean code itself
Container-managed persistence:
The entity bean’s persistence is automatically maintained
by the EJB container
This is the easiest way, and often EJB containers do a
better job because they provide extra features like
connection pooling, load balancing, etc.
This method is known to be extremely reliable, since
CMP code is usually well tested
Persistence logic is kept in “declarative code” in the EJB
deployment descriptor
Session and Entity Beans
An EJB Autopsy
The remote interface
Describes the interface provided to EJB clients
The enterprise bean class
The implementation of the bean
The home interface
Describe how client can create, find, and
remove EJB instances
EJP Autopsy
The Remote Interface
Describes the interface provided to EJB clients
Must extends javax.ejb.EJBObject
This interface usually provides a number of
accessor methods (getters and setters) for the
bean’s fields, as well as all business methods
The Enterprise Bean Class
The implementation of the bean
This is where the methods exported in the remote
interface are defined
Business logic and data operations occur here
EJB classes must implement one of the following
interfaces: javax.ejb.SessionBean, javax.ejb.EntityBean
The Home Interface
The home interface describes any methods not
requiring access to a particular bean instance
Methods for creating, finding, and deleting bean
instances
Must extend javax.ejb.EJBHome
EJB Naming Conventions
Enterprise bean class:
<name>Bean, e.g. CustomerBean
Home interface:
<name>Home, e.g. CustomerHome
Remote interface:
<name>, e.g. Customer
EJB Client Operation
An EJB client uses an EJB by first locating its
home object
The methods on this home object are declared in the
home interface
The home object is located using JNDI
The client tells JNDI what name the EJB goes by, and
JNDI gives a home interface for that EJB
Once a home object is obtained, the client calls
some home methods to access the EJB
e.g. The client may call “create” to create a new
instance, “remove” to delete an instance, “findXYZ” to
search for EJBs.
References
Developing Enterprise Applications Using the J2EE Platform,
http://java.sun.com/developer/onlineTraining/J2EE/Intro2/j2ee.html
Sang Shin, EJB Overview, http://www.javapassion.com/j2ee

More Related Content

What's hot

Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
Peter R. Egli
 
Java EE EJB Applications
Java EE EJB ApplicationsJava EE EJB Applications
Java EE EJB Applications
DevelopIntelligence
 
Ch4 ejb
Ch4 ejbCh4 ejb
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
Return on Intelligence
 
Ejb notes
Ejb notesEjb notes
Ejb notes
Mumbai Academisc
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance Features
Emprovise
 
Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
Armen Arzumanyan
 
EJB 2
EJB 2EJB 2
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business Logic
Emprovise
 
enterprise java bean
enterprise java beanenterprise java bean
enterprise java bean
Jitender Singh Lodhi
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
phanleson
 
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
 
EJB .
EJB .EJB .
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
Sourabrata Mukherjee
 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questions
guest346cb1
 
J2ee web services(overview)
J2ee web services(overview)J2ee web services(overview)
J2ee web services(overview)
Prafull Jain
 
J2 ee architecture
J2 ee architectureJ2 ee architecture
J2 ee architecture
Krishna Mer
 
J2 ee tutorial ejb
J2 ee tutorial ejbJ2 ee tutorial ejb
J2 ee tutorial ejb
Niraj Bharambe
 
J2EE Architecture Explained
J2EE  Architecture ExplainedJ2EE  Architecture Explained
J2EE Architecture Explained
Adarsh Kr Sinha
 
Java unit 4_cs_notes
Java unit 4_cs_notesJava unit 4_cs_notes
Java unit 4_cs_notes
Niraj Bharambe
 

What's hot (20)

Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
Java EE EJB Applications
Java EE EJB ApplicationsJava EE EJB Applications
Java EE EJB Applications
 
Ch4 ejb
Ch4 ejbCh4 ejb
Ch4 ejb
 
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
Ejb notes
Ejb notesEjb notes
Ejb notes
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance Features
 
Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
 
EJB 2
EJB 2EJB 2
EJB 2
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business Logic
 
enterprise java bean
enterprise java beanenterprise java bean
enterprise java bean
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another Introduction
 
EJB .
EJB .EJB .
EJB .
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questions
 
J2ee web services(overview)
J2ee web services(overview)J2ee web services(overview)
J2ee web services(overview)
 
J2 ee architecture
J2 ee architectureJ2 ee architecture
J2 ee architecture
 
J2 ee tutorial ejb
J2 ee tutorial ejbJ2 ee tutorial ejb
J2 ee tutorial ejb
 
J2EE Architecture Explained
J2EE  Architecture ExplainedJ2EE  Architecture Explained
J2EE Architecture Explained
 
Java unit 4_cs_notes
Java unit 4_cs_notesJava unit 4_cs_notes
Java unit 4_cs_notes
 

Similar to Ejb intro

Aravind vinnakota ejb_architecture
Aravind vinnakota ejb_architectureAravind vinnakota ejb_architecture
Aravind vinnakota ejb_architecture
tayab4687
 
ADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.pptADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.ppt
rani marri
 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
achraf_ing
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
Tharindu Weerasinghe
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee Overview
Atul Shridhar
 
J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical Overview
Svetlin Nakov
 
Abstract #236765 advanced essbase java api tips and tricks
Abstract #236765 advanced essbase java api tips and tricksAbstract #236765 advanced essbase java api tips and tricks
Abstract #236765 advanced essbase java api tips and tricks
timtow
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
Bill Lyons
 
Unite5-EJB-2019.ppt
Unite5-EJB-2019.pptUnite5-EJB-2019.ppt
Unite5-EJB-2019.ppt
Krishna900061
 
Topic4 Application Servers
Topic4 Application ServersTopic4 Application Servers
Topic4 Application Servers
sanjoysanyal
 
Java j2eeTutorial
Java j2eeTutorialJava j2eeTutorial
Java j2eeTutorial
QUONTRASOLUTIONS
 
Virtual classroom
Virtual classroomVirtual classroom
Virtual classroom
Krishna Chaithanya
 
B Shilpa
B ShilpaB Shilpa
Real world java_ee_patterns
Real world java_ee_patternsReal world java_ee_patterns
Real world java_ee_patterns
Alassane Diallo
 
Session 3 Tp3
Session 3 Tp3Session 3 Tp3
Session 3 Tp3
phanleson
 
Design patterns
Design patternsDesign patterns
Design patterns
revamptechnologies
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)
vikram singh
 
מתפ
מתפמתפ
מתפ
Liran Zelkha
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
vikram singh
 
Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2
vikram singh
 

Similar to Ejb intro (20)

Aravind vinnakota ejb_architecture
Aravind vinnakota ejb_architectureAravind vinnakota ejb_architecture
Aravind vinnakota ejb_architecture
 
ADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.pptADVANCED JAVA MODULE I & II.ppt
ADVANCED JAVA MODULE I & II.ppt
 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee Overview
 
J2EE - Practical Overview
J2EE - Practical OverviewJ2EE - Practical Overview
J2EE - Practical Overview
 
Abstract #236765 advanced essbase java api tips and tricks
Abstract #236765 advanced essbase java api tips and tricksAbstract #236765 advanced essbase java api tips and tricks
Abstract #236765 advanced essbase java api tips and tricks
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
 
Unite5-EJB-2019.ppt
Unite5-EJB-2019.pptUnite5-EJB-2019.ppt
Unite5-EJB-2019.ppt
 
Topic4 Application Servers
Topic4 Application ServersTopic4 Application Servers
Topic4 Application Servers
 
Java j2eeTutorial
Java j2eeTutorialJava j2eeTutorial
Java j2eeTutorial
 
Virtual classroom
Virtual classroomVirtual classroom
Virtual classroom
 
B Shilpa
B ShilpaB Shilpa
B Shilpa
 
Real world java_ee_patterns
Real world java_ee_patternsReal world java_ee_patterns
Real world java_ee_patterns
 
Session 3 Tp3
Session 3 Tp3Session 3 Tp3
Session 3 Tp3
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Enterprise Java Beans( E)
Enterprise  Java  Beans( E)Enterprise  Java  Beans( E)
Enterprise Java Beans( E)
 
מתפ
מתפמתפ
מתפ
 
Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2Enterprise java beans(ejb) update 2
Enterprise java beans(ejb) update 2
 
Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2Enterprise java beans(ejb) Update 2
Enterprise java beans(ejb) Update 2
 

Recently uploaded

Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 

Recently uploaded (20)

Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 

Ejb intro

  • 2. What are EJBs? They are components that can be connected to form a system They can represent data They can represent behavior Usually, EJBs fall into only one of these categories They are typically used in the server tier EJBs can be persisted EJBs can interact with other EJBs
  • 3. Advantages of EJBs EJBs are reusable components Can be reused in different parts of the system Can be packaged into libraries and sold EJBs Can be combined visually using development IDEs E.g. Visual Age, Visual Café EJBs provide convenient abstractions so it do not require you to write: Multi-threaded, multiple access code Database access code (e.g. JDBC) Network communication code (i.e. it uses RMI) for client/server communication Network communication code for EJB to EJB communication Transaction management code EJBs from different businesses can interact easily This is because of their well-defined interfaces
  • 4. EJB in the Big Picture of J2EE
  • 5.
  • 6. EJB Communication EJBs use IIOP as the wire protocol Therefore, EJBs are compatible with RMI (i.e., RMI over IIOP) and CORBA libraries Thus, you could write an EJB client in any language that supports CORBA
  • 7. EJB as Client/Server Middleware Think of EJBs as just another Client/Server middleware like RMI, CORBA, or Web Services The EJB instance itself is the server EJBs have clients (objects that call its methods) One complication is that EJB clients can be: Java Applets and Applications (using RMI or CORBA) Non-Java applications (using CORBA) JSPs and Servlets (using RMI or CORBA) Other EJBs (using RMI or CORBA)
  • 8. EJBs & 3-Tiered Architectures Applet Web Page Servlets & JSPs EJBs Database Client Tier Server Tier Database Tier In enterprise systems, EJB clients are usually: Servlets, JSPs, or Other EJBs
  • 9. EJBs & Multi-Tiered Architectures Applet Web Page Servlets & JSPs EJBs Database 3rd Party EJBs
  • 10. How EJBs Change Things EJBs are most suitable for developing business logic and data manipulation If all of the business logic operations and data manipulations are done using EJBs, the JSPs and Servlets will be focused mainly on displaying the results of those operations Session EJBs: Used to represent system behavior (i.e. business logic) e.g. Storing products to purchase in the shopping cart Entity EJBs: Used to represent & manipulate system data e.g. Finding products that match a search term
  • 11. Application Servers Containers where EJBs (and JSPs and servlets) are executed Provide EJB functionality, including: Persistence through databases (using JDBC) Transactions (using Java Transaction Service) Can provide advanced features, including: Load balancing Database connection pooling Here are the major application servers: SJS AP, WebLogic (BEA), Internet Application Server or iAS (Oracle), WebSphere (IBM)
  • 12. Alternatives to EJBs Web Services are one of the technologies competing with EJBs Web services use the SOAP protocol to exchange information with some server SOAP uses an XML format to exchange request and response information via HTTP Due to SOAP's well-defined protocol, Web Services can be used to exchange information between businesses (B2B) Web services provide one or more remote method that can be accessed easily from other applications
  • 13. Alternatives to EJBs CORBA objects provide some functionality similar to EJBs: Persistence (of CORBA object data) Transactions (between CORBA objects) Security (between CORBA objects) CORBA and EJBs are closely related, in fact, they use the same wire protocol: IIOP In some sense, EJBs can be considered to be an enhanced version of CORBA Except that EJBs can only be created in Java
  • 15. Types of Enterprise Beans Session beans: Also called business process objects They represent the business logic of the system Their lifetime is usually an entire session When a session is done, the session bean expires i.e. Session bean instances exist as long as a specific user is using the system Entity beans: Also called business data objects They represent persistent data Often the data persistence is managed through a database, using JDBC
  • 16. Subtypes of Session Beans Stateful: Used for operations that require multiple requests to be completed Maintain data between requests Stateless: Used for operations that can be performed in a single request Do not maintain persistent data between subsequent requests from a given client
  • 17. Entity Beans Explained Entity beans represent data in the system In addition, entity beans are used to search for, modify, create and delete data Usually, this data resides in a relational database Each entity bean typically represents a single row in some database table An entity bean instance exists as long as the data is being used When the EJB client is done with the instance, the entity bean instance usually returns to a bean pool The client for an entity bean is typically a session bean, since behavior usually involves the manipulation of data
  • 18. Subtypes of Entity Beans Bean-managed persistence: The entity bean handles its own persistence Often via JDBC (or SQL/J) to a database The bean author is required to write persistence- management code into the bean code itself Container-managed persistence: The entity bean’s persistence is automatically maintained by the EJB container This is the easiest way, and often EJB containers do a better job because they provide extra features like connection pooling, load balancing, etc. This method is known to be extremely reliable, since CMP code is usually well tested Persistence logic is kept in “declarative code” in the EJB deployment descriptor
  • 20. An EJB Autopsy The remote interface Describes the interface provided to EJB clients The enterprise bean class The implementation of the bean The home interface Describe how client can create, find, and remove EJB instances
  • 22.
  • 23.
  • 24. The Remote Interface Describes the interface provided to EJB clients Must extends javax.ejb.EJBObject This interface usually provides a number of accessor methods (getters and setters) for the bean’s fields, as well as all business methods
  • 25. The Enterprise Bean Class The implementation of the bean This is where the methods exported in the remote interface are defined Business logic and data operations occur here EJB classes must implement one of the following interfaces: javax.ejb.SessionBean, javax.ejb.EntityBean
  • 26. The Home Interface The home interface describes any methods not requiring access to a particular bean instance Methods for creating, finding, and deleting bean instances Must extend javax.ejb.EJBHome
  • 27. EJB Naming Conventions Enterprise bean class: <name>Bean, e.g. CustomerBean Home interface: <name>Home, e.g. CustomerHome Remote interface: <name>, e.g. Customer
  • 28. EJB Client Operation An EJB client uses an EJB by first locating its home object The methods on this home object are declared in the home interface The home object is located using JNDI The client tells JNDI what name the EJB goes by, and JNDI gives a home interface for that EJB Once a home object is obtained, the client calls some home methods to access the EJB e.g. The client may call “create” to create a new instance, “remove” to delete an instance, “findXYZ” to search for EJBs.
  • 29. References Developing Enterprise Applications Using the J2EE Platform, http://java.sun.com/developer/onlineTraining/J2EE/Intro2/j2ee.html Sang Shin, EJB Overview, http://www.javapassion.com/j2ee