SlideShare a Scribd company logo
EJB 3.1 Overview
Vladan Pulec
Agenda
 EJB features and functionality
 Brief demo
New Features
• Previous versions of EJBs suffered from:
– Heavyweight programming model
– Direct use of JNDI
– Verbose XML descriptor
• EJB 3 eliminates this by:
– Metadata annotations
– Minimal deployment descriptors (optional)
– Dependency injection
Component Types
EJB Technology
Session
(Stateless, stateful,
singleton)
Message-Driven
Session EJB Components:
• Business logic running within an EJB
Component
Message-Driven Beans:
• Asynchronous message consumer
• Different operational characteristics from
session beans
Entity EJBs:
• replaced by JPA (Java Persistence API)
•Supported only for backward compatibility
EJB Tiers
• Session beans act as a façade for the entity
components:
– Minimizes network overhead
– Clearer separation of concerns
• Design pattern (not mandated by Java EE
specification)
– Service tier (mostly session beans and message-driven
beans)
– Object-relational mapping tier (entity classes and
related supporting classes)
Session Façade Example
web EJB
Entity ClassesSession Beans
Client
Client
Client
FinanceSessionBean
PaymentSessionBean
Order
Payment
Credit Card
Authorization
Database
EJB Component Model
 Components are encapsulated within the EJB
container
 Container provides proxies to allow limited access
to the components
 Clients make calls to the interfaces (container
exposes proxies, not the actual beans)
 Container provides life-cycle management,
security, resource management, and transaction
management for the components
 Container also provides timer services and
monitors message queue (for message-driven
beans)
EJB Container
• Resource management
– Encapsulates access to external resources
– Connection pooling
• Life-cycle management
• Isolates implementation classes from clients
• Timer services
– scheduled work
• Monitors message queue
Embedded EJB Container (EJB lite)
 Subset of EJB functionality
 Added in Java EE 6
 Runs outside of an EJB container (using SDK only)
No application server required
 Supports stateless, stateful, and singleton
components
 Local and no interface only
 Synchronous invocation only
 Container-managed security and transactions
 Declarative and programmatic security
EJB Components
 Session Beans
Stateless
Stateful
Singleton
 Message-Driven Beans
Timer Service
• Container invokes either a stateless session
bean or Message-Driven bean
– Use timer service in the bean to configure the
timer
• Injected
• Via context
– Configure timing
– Configure timeout method
Difference between stateless and stateful session beans
EJB Objects
• EJB components are never called directly by
clients
• Clients get a reference to the component via
EJBObject, which acts as a proxy
– Stateful beans require separate proxies for each
call
– Stateless beans share the same proxy
Anatomy of a session bean
• Consists of an interface and implementation
class
• Must be a concrete class (cannot be final or
abstract)
• Must have no argument constructor
• Cannot start with “’ejb”
• Business and life-cycle methods
Session bean best practices
• Choose bean type carefully
– Stateless session beans fit most of the needs
• Examine interface types
– Remote interface require network access and will be
slow. Use local in using within the same JVM
• For DI, make sure not to inject stateful session
bean into a stateless bean
• Examine what kind of data will be stored in a
conversational state (stateful beans)
– Use primitive variables rather than large nested
composite objects

More Related Content

PDF
Java unit 14
PPTX
PPT
Learn spring at amc square learning
PPTX
J2 ee architecture
DOC
Jdbc drivers
PPTX
Design patterns
PPT
eSobi Website Multilayered Architecture
PPTX
J2ee web services(overview)
Java unit 14
Learn spring at amc square learning
J2 ee architecture
Jdbc drivers
Design patterns
eSobi Website Multilayered Architecture
J2ee web services(overview)

What's hot (20)

PDF
Ejb intro
PPTX
Java.sql package
PPT
JDBC Architecture and Drivers
PPTX
Middleware Services for Search, Online Ads and Recommender
DOCX
J2EE and layered architecture
ODP
XPages: The Next Step In Your Life As A Notes Developer
PPTX
Bojan Veljanovski - Modular Software Architecture and Design (Code Camp 2016)
PPT
PDF
Mule ESB Fundamentals
PPTX
Java Training in Chennai
PPTX
Java ee introduction
PPTX
Mule esb overview
PPT
Complete integration with mule esb
PDF
Domino X Pages
PPTX
Mule: Java Component
PPT
Networking chapter IV
PPSX
Software Design Patterns
PPTX
Neuro4j Workflow Overview
PDF
Getting Started with the NetBeans Platform
Ejb intro
Java.sql package
JDBC Architecture and Drivers
Middleware Services for Search, Online Ads and Recommender
J2EE and layered architecture
XPages: The Next Step In Your Life As A Notes Developer
Bojan Veljanovski - Modular Software Architecture and Design (Code Camp 2016)
Mule ESB Fundamentals
Java Training in Chennai
Java ee introduction
Mule esb overview
Complete integration with mule esb
Domino X Pages
Mule: Java Component
Networking chapter IV
Software Design Patterns
Neuro4j Workflow Overview
Getting Started with the NetBeans Platform
Ad

Viewers also liked (6)

PPT
Android ui patterns
PPT
Whats New in Jelly Bean
PPTX
Java 8
PPT
Android ui patterns
PPTX
Java Web services
PDF
How to Become a Thought Leader in Your Niche
Android ui patterns
Whats New in Jelly Bean
Java 8
Android ui patterns
Java Web services
How to Become a Thought Leader in Your Niche
Ad

Similar to Enterprise beans (20)

PDF
EJB 3.0 - Yet Another Introduction
PPT
PPTX
The Latest in Enterprise JavaBeans Technology
PPT
Unite5-EJB-2019.ppt
PDF
EJB 3.0 and J2EE
PDF
EJB 3.1 by Bert Ertman
PPT
Aravind vinnakota ejb_architecture
PPT
Virtual classroom
PDF
Connecting ejb with mule
PDF
Contextual Dependency Injection for Apachecon 2010
PPTX
EJB3 Basics
PDF
Enterprise Java Beans - EJB
PDF
Introcution to EJB
DOC
Java online training from hyderabad
PDF
EJB Interview Questions
PPTX
enterprise java bean
PDF
Real world java_ee_patterns
PPT
Session 2 Tp2
PDF
Ejb intro
PPT
ejb.ppt java lecture notes enterprise java
EJB 3.0 - Yet Another Introduction
The Latest in Enterprise JavaBeans Technology
Unite5-EJB-2019.ppt
EJB 3.0 and J2EE
EJB 3.1 by Bert Ertman
Aravind vinnakota ejb_architecture
Virtual classroom
Connecting ejb with mule
Contextual Dependency Injection for Apachecon 2010
EJB3 Basics
Enterprise Java Beans - EJB
Introcution to EJB
Java online training from hyderabad
EJB Interview Questions
enterprise java bean
Real world java_ee_patterns
Session 2 Tp2
Ejb intro
ejb.ppt java lecture notes enterprise java

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
KodekX | Application Modernization Development
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Electronic commerce courselecture one. Pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Modernizing your data center with Dell and AMD
Reach Out and Touch Someone: Haptics and Empathic Computing
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Understanding_Digital_Forensics_Presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
Electronic commerce courselecture one. Pdf
Unlocking AI with Model Context Protocol (MCP)
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Modernizing your data center with Dell and AMD

Enterprise beans

  • 2. Agenda  EJB features and functionality  Brief demo
  • 3. New Features • Previous versions of EJBs suffered from: – Heavyweight programming model – Direct use of JNDI – Verbose XML descriptor • EJB 3 eliminates this by: – Metadata annotations – Minimal deployment descriptors (optional) – Dependency injection
  • 4. Component Types EJB Technology Session (Stateless, stateful, singleton) Message-Driven Session EJB Components: • Business logic running within an EJB Component Message-Driven Beans: • Asynchronous message consumer • Different operational characteristics from session beans Entity EJBs: • replaced by JPA (Java Persistence API) •Supported only for backward compatibility
  • 5. EJB Tiers • Session beans act as a façade for the entity components: – Minimizes network overhead – Clearer separation of concerns • Design pattern (not mandated by Java EE specification) – Service tier (mostly session beans and message-driven beans) – Object-relational mapping tier (entity classes and related supporting classes)
  • 6. Session Façade Example web EJB Entity ClassesSession Beans Client Client Client FinanceSessionBean PaymentSessionBean Order Payment Credit Card Authorization Database
  • 7. EJB Component Model  Components are encapsulated within the EJB container  Container provides proxies to allow limited access to the components  Clients make calls to the interfaces (container exposes proxies, not the actual beans)  Container provides life-cycle management, security, resource management, and transaction management for the components  Container also provides timer services and monitors message queue (for message-driven beans)
  • 8. EJB Container • Resource management – Encapsulates access to external resources – Connection pooling • Life-cycle management • Isolates implementation classes from clients • Timer services – scheduled work • Monitors message queue
  • 9. Embedded EJB Container (EJB lite)  Subset of EJB functionality  Added in Java EE 6  Runs outside of an EJB container (using SDK only) No application server required  Supports stateless, stateful, and singleton components  Local and no interface only  Synchronous invocation only  Container-managed security and transactions  Declarative and programmatic security
  • 10. EJB Components  Session Beans Stateless Stateful Singleton  Message-Driven Beans
  • 11. Timer Service • Container invokes either a stateless session bean or Message-Driven bean – Use timer service in the bean to configure the timer • Injected • Via context – Configure timing – Configure timeout method
  • 12. Difference between stateless and stateful session beans
  • 13. EJB Objects • EJB components are never called directly by clients • Clients get a reference to the component via EJBObject, which acts as a proxy – Stateful beans require separate proxies for each call – Stateless beans share the same proxy
  • 14. Anatomy of a session bean • Consists of an interface and implementation class • Must be a concrete class (cannot be final or abstract) • Must have no argument constructor • Cannot start with “’ejb” • Business and life-cycle methods
  • 15. Session bean best practices • Choose bean type carefully – Stateless session beans fit most of the needs • Examine interface types – Remote interface require network access and will be slow. Use local in using within the same JVM • For DI, make sure not to inject stateful session bean into a stateless bean • Examine what kind of data will be stored in a conversational state (stateful beans) – Use primitive variables rather than large nested composite objects