SlideShare a Scribd company logo
1 of 30
Download to read offline
Understanding EJB




   By:
   Asha Pathik
   Aniruddha Ray
Saastha Infotech

Agenda

• Overview and Basic Concepts
  –   What is EJB?
  –   When to use EJB
  –   Containers
  –   Evolution of EJB
• EJB Components
  –   Types of Enterprise Beans
  –   Session Beans
  –   Entity Beans
  –   Message-driven Beans
• Creating an EJB
• Summary


                                  2
Saastha Infotech




Overview and Basic concepts
        What is EJB?




             3
Saastha Infotech

What is EJB ( Enterprise Java Beans )?

• EJB is the J2EE standard for developing and
  deploying server-side distributed components in
  java
• It defines a contract between components and
  application servers that enables any component to
  run on any compliant server
   –   it is the ubiquitous industry standard
   –   portability is possible
   –   rapid application development
   –   physically, EJB is two things
        • a specification
        • a set of Java interfaces



                                     4
Saastha Infotech




Overview and Basic concepts
       When to use EJB




             5
Saastha Infotech

When to use EJB

• For large scale applications where resources and
  data are distributed.
• When the application is running on different servers
  at many locations.
• Where scalability is critical.
• Where transactions are required to ensure data
  integrity
• When a variety of clients need to handled




                          6
Saastha Infotech




Overview and Basic concepts
Evolution of Enterprise JavaBeans




               7
Saastha Infotech

Evolution of Enterprise Java Beans – Part 1

• EJB release 1.0 focused on the following aspects:
   – defined the distinct “EJB roles” that are assumed by the component
     architecture
   – defined the client view of enterprise beans
   – defined the developer’s view of enterprise beans
   – defined the responsibilities of EJB Container provider and Server
     Provider
   – defined the format of ejb.jar file, EJB’s unit of deployment
• EJB release 1.1 augmented these with following:
   – provided better support for application assembly and deployment
   – specified in greater detail the responsibilities of the individual EJB
     roles


                                   8
Saastha Infotech

Evolution of Enterprise Java Beans – Part 2

• EJB release 2.0 focused on the following aspects:
   – defined message-driven bean and the integration with the JMS
   – provided local client view and support for efficient, lightweight
     access to EJB from local clients
   – defined new architecture for container persistence
   – support for management of relationships among entity beans
   – declarative query syntax for finder and select methods for entity
     beans with container-managed persistence
   – support for additional methods in home interface
   – support for run-as security identity
   – provided for network interoperability among servers




                                  9
Saastha Infotech

Evolution of Enterprise Java Beans – Part 3

• EJB release 2.1 focused on the following aspects:
   – enabling enterprise beans to implement and utilize web services
   – providing a container-managed timer services
   – enhancing EJB QL with additional ORDER BY and aggregate
     operators
   – enhancing the message-driven bean component type to other
     messaging types
• The EJB release 3.0 is focused on a simplification of the
  Enterprise JavaBeans architecture from the developer’s
  point of view.




                                10
Saastha Infotech




Overview and Basic concepts
         Containers




            11
Saastha Infotech

Containers

• Are the interface between a component and low-level
  platform-specific functionality that supports the
  component
   – components are simple set of programs that are capable of
     performing a particular business logic
• Provide configurable settings : like data accessibility
• Manages non-configurable settings like enterprise
  bean and servlet life cycles, database connection
  resource pooling, data persistence etc.
• Before a J2EE component can be executed, it must
  be assembled into J2EE application and deployed
  into its container


                                12
Saastha Infotech

EJB Components




                 13
Saastha Infotech




EJB Components
  Session Beans




       14
Saastha Infotech

Session Bean : Concepts

• A Session Bean is non-persistent object that
  implements some business logic.
   –   private to one client connection
   –   represents an interactive session
   –   not recoverable after system crash or shutdown!
   –   when client terminates, bean terminates i.e. no longer active
• A Stateful Session Bean has Conversational State
   – activation/ passivation of a Bean is possible
   – E.g. items reviewed in a session at some sites.
• A Stateless Session Bean has no Conversational State
   –   no activation or passivation
   –   pooling of stateless Session Beans by the container
   –   very efficient
   –   E.g. computing value using a formula.
                                   15
Saastha Infotech

Stateful Session Bean : Part(1)

Conversational Bean
• Consists of attributes and referenced objects :
   –   all non-transient attributes of the Bean
   –   referenced data in the database
   –   open connections to network
   –   references to other Beans
   –   etc.
• Exists during one client session
• A Conversation State is not persistent and is not
  automatically rolled back when a transaction fails!



                                    16
Saastha Infotech

Stateful Session Bean : Part(2)

• Passivation:
   – container serializes Bean instance and saves it to disk
   – preparation for Passivation is done with the method ejbPassivate:
       • close all existing connections
       • resolve all external references
• Activation:
   – de-serialize Bean instance from disk
   – afterwards, ejbActivate method is invoked to:
       • re-establish external references
       • re-establish connections
• If non-serializable objects are part of the state, these
  methods must be implemented in the Bean class

                                     17
Saastha Infotech

Stateful Session Bean : Life Cycle




                       18
Saastha Infotech

Stateless Session Bean

• All instances are equivalent
• Private to one client only during one call
• Pooled while not in use




                           19
Saastha Infotech




EJB Components
  Entity Beans




      20
Saastha Infotech

Entity Bean : Concept

• An Entity Bean represents an object-oriented view of
  some entities stored in a persistent, crash-resistant
  storage (usually a relational database)
   – persistent and transient (modifier transient) attributes are allowed,
     but only persistent attributes will be saved in database.
   – each entity bean typically has an underlying table in a RDBMS(
     business data), and each instance of the bean corresponds to a row
     in that table.
   – transactional and recoverable on a server crash.
• Shared among multiple clients ( no per-client state)
• Primary Key : a unique attribute of bean or a serializable
  class (Primary Key Class) with one or more attributes
• Two Beans with same Home Interface and same
  Primary Key are regarded as identical ( Bean Identity)
                                 21
Saastha Infotech

Persistence Management

• Bean-Managed Persistence (BMP) : any java-accessible
  data storage is possible
   – implements persistence mechanisms in ejbLoad resp. ejbStore
   – implements ejbActivate, ejbPassivate and ejbRemove
   – ejbCreate must return a ‘real’ primary key ( e.g. return pk;)
• Container-Managed Persistence (CMP) : Container
  controls access to (usually) a relational database
   – empty implementation of ejbLoad, ejbStore, ejbActivate,
     ejbPassivate and ejbRemove
   – ejbCreate returns ‘null’ as primary key ( return null)
   – Object-Relational Mapping between Bean attributes and database
     entries ( Vendor –specific)
   – more details later


                              22
Saastha Infotech


Primary Key

• A Primary Key of an Entity Bean consists of one or more
  persistent Bean attributes
   – values of primary key attributes must be unique for a Bean instance
   – primary key attributes must be serializable
• The primary key class …
   – is a serializable class with one or several attributes which ( together)
     acts as primary key of an Entity Bean
       • one can use e.g. Long or String for single primary key attributes or
         specific classes
       • all primary key attributes must be persistent Bean attributes
   – must be declared in the Bean’s Deployment Descriptor




                                     23
Saastha Infotech

Activation and Passivation

• The EJB Container can passivate unused Entity
  Beans
  – ejbPassivate is invoked
  – used resources ( e.g. database connections, references to other
    Beans etc. ) are freed
  – bean instance is pooled
• The Bean is activated when used again
  – an instance of this Bean is taken from the pool
  – ejbActivate is invoked
  – needed resources are occupied ( e.g. database connections are
    re-established)



                               24
Saastha Infotech

Entity Bean : Life Cycle




                       25
Saastha Infotech




EJB Components
Message-driven Beans




        26
Saastha Infotech

Message-Driven Bean – Concepts (1)

• Like a Stateless Session Bean, a Message-driven Bean
  only provides a piece of business logic without state
  management ( similar life cycle)
• A Message-driven bean must implement the interfaces
  javax.ejb.MessageDrivenBean and
  javax.ejb.MessageListener
   – MessageListener declares a method
     public void onMessage(Message msg)
     which will be invoked when message arrives
• A Message-driven Bean has no client-visible interfaces



                               27
Saastha Infotech

Message-Driven Bean – Concepts (2)

• A Message-driven bean is assigned to a JMS
  destination by means of the Deployment Descriptor
  element
   – message-driven destination
• The bean is invoked by the container, when a JMS
  message to this destination arrives




                                  28
Saastha Infotech

Message-Driven Bean – Concepts (3)

• A message driven bean is an enterprise bean that
  allows J2EE applications to process messages
  asynchronously
• It acts a JMS listener, which is similar to an event
  listener except that it receives messages instead of
  events
• The messages can be sent to any J2EE component
  or a non-J2EE system using JMS
• It retains no data or conversational state




                           29
Saastha Infotech

Contents of an EJB

• Interfaces: The remote and home interface for
  remote access. Local and local home accesses for
  local access.
• Enterprise bean class: Implements the methods
  defined in the above interfaces.
• Deployment descriptor: An XML file that specifies
  information about the bean such as its type,
  transaction attributes, etc.
• Helper classes: non-bean classes needed by the
  enterprise bean class such as utility and exception
  classes.




                          30

More Related Content

What's hot

Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJBPeter R. Egli
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance FeaturesEmprovise
 
Ejb3.1 for the starter
Ejb3.1 for the starterEjb3.1 for the starter
Ejb3.1 for the startershohancse
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Rohit Kelapure
 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questionsguest346cb1
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1phanleson
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEEFahad Golra
 
JEE Course - EJB
JEE Course - EJBJEE Course - EJB
JEE Course - EJBodedns
 
0012
00120012
0012none
 

What's hot (19)

Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)Enterprise JavaBeans(EJB)
Enterprise JavaBeans(EJB)
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
Session bean
Session beanSession bean
Session bean
 
Enterprise java beans
Enterprise java beansEnterprise java beans
Enterprise java beans
 
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
EJB3 Advance Features
EJB3 Advance FeaturesEJB3 Advance Features
EJB3 Advance Features
 
EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
 
Ejb3.1 for the starter
Ejb3.1 for the starterEjb3.1 for the starter
Ejb3.1 for the starter
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010
 
EJB Interview Questions
EJB Interview QuestionsEJB Interview Questions
EJB Interview Questions
 
Ch4 ejb
Ch4 ejbCh4 ejb
Ch4 ejb
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
 
JEE Course - EJB
JEE Course - EJBJEE Course - EJB
JEE Course - EJB
 
0012
00120012
0012
 
J2ee architecture
J2ee architectureJ2ee architecture
J2ee architecture
 
Java beans
Java beansJava beans
Java beans
 
Ejb intro
Ejb introEjb intro
Ejb intro
 
Java ee introduction
Java ee introductionJava ee introduction
Java ee introduction
 

Similar to EJB 3.0 and J2EE

The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologySimon Ritter
 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionKelum Senanayake
 
Enterprise beans
Enterprise beansEnterprise beans
Enterprise beansvpulec
 
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010Arun Gupta
 
Connecting ejb with mule
Connecting ejb with muleConnecting ejb with mule
Connecting ejb with muleRuman Khan
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGMarakana Inc.
 
Java online training from hyderabad
Java online training from hyderabadJava online training from hyderabad
Java online training from hyderabadrevanthonline
 
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-finalRohit Kelapure
 
Ejb course in-mumbai
Ejb course in-mumbaiEjb course in-mumbai
Ejb course in-mumbaivibrantuser
 

Similar to EJB 3.0 and J2EE (20)

The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another Introduction
 
Unite5-EJB-2019.ppt
Unite5-EJB-2019.pptUnite5-EJB-2019.ppt
Unite5-EJB-2019.ppt
 
Enterprise beans
Enterprise beansEnterprise beans
Enterprise beans
 
Virtual classroom
Virtual classroomVirtual classroom
Virtual classroom
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
 
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
 
Jsf+ejb 50
Jsf+ejb 50Jsf+ejb 50
Jsf+ejb 50
 
P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptx
 
UNIT 4.pptx
UNIT 4.pptxUNIT 4.pptx
UNIT 4.pptx
 
Connecting ejb with mule
Connecting ejb with muleConnecting ejb with mule
Connecting ejb with mule
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUG
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
 
Hibernate
HibernateHibernate
Hibernate
 
Java online training from hyderabad
Java online training from hyderabadJava online training from hyderabad
Java online training from hyderabad
 
Advance java1.1
Advance java1.1Advance java1.1
Advance java1.1
 
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
 
Ejb (1)
Ejb (1)Ejb (1)
Ejb (1)
 
Ejb course in-mumbai
Ejb course in-mumbaiEjb course in-mumbai
Ejb course in-mumbai
 

More from Aniruddha Ray (Ani)

3D Cameras - Evolution (Films to 3D) and Road Ahead
3D Cameras - Evolution (Films to 3D) and Road Ahead3D Cameras - Evolution (Films to 3D) and Road Ahead
3D Cameras - Evolution (Films to 3D) and Road AheadAniruddha Ray (Ani)
 
IIM A PGPX - 6th Batch - Snapshot
IIM A PGPX - 6th Batch - SnapshotIIM A PGPX - 6th Batch - Snapshot
IIM A PGPX - 6th Batch - SnapshotAniruddha Ray (Ani)
 
PGPX - One Day Theatre - Lessons
PGPX - One Day Theatre -  Lessons PGPX - One Day Theatre -  Lessons
PGPX - One Day Theatre - Lessons Aniruddha Ray (Ani)
 
TVS Suzuki JV Split - Analysis on Corp Governance
TVS Suzuki JV Split - Analysis on Corp GovernanceTVS Suzuki JV Split - Analysis on Corp Governance
TVS Suzuki JV Split - Analysis on Corp GovernanceAniruddha Ray (Ani)
 
Ani's Small World - 35 Revolutions Around The Sun
Ani's Small World  - 35 Revolutions Around The SunAni's Small World  - 35 Revolutions Around The Sun
Ani's Small World - 35 Revolutions Around The SunAniruddha Ray (Ani)
 
Containerization and India - Status
Containerization and India - StatusContainerization and India - Status
Containerization and India - StatusAniruddha Ray (Ani)
 
Capital Account Convertibility and India - Status
Capital Account Convertibility and India - StatusCapital Account Convertibility and India - Status
Capital Account Convertibility and India - StatusAniruddha Ray (Ani)
 
Exploring Consumers Mind and Heart - Apartment-Wallahs
Exploring Consumers Mind and Heart  - Apartment-WallahsExploring Consumers Mind and Heart  - Apartment-Wallahs
Exploring Consumers Mind and Heart - Apartment-WallahsAniruddha Ray (Ani)
 
IIMA PGPX - FT Ranking Communique
IIMA PGPX - FT Ranking CommuniqueIIMA PGPX - FT Ranking Communique
IIMA PGPX - FT Ranking CommuniqueAniruddha Ray (Ani)
 
Leadership Tips from Jack Welch - Summary by Ani
Leadership Tips from Jack Welch  - Summary by AniLeadership Tips from Jack Welch  - Summary by Ani
Leadership Tips from Jack Welch - Summary by AniAniruddha Ray (Ani)
 
The Long Tail - A Summary by Ani
The Long Tail  - A Summary by AniThe Long Tail  - A Summary by Ani
The Long Tail - A Summary by AniAniruddha Ray (Ani)
 

More from Aniruddha Ray (Ani) (19)

Best Bourbons
Best BourbonsBest Bourbons
Best Bourbons
 
10 Best - Single Malt Scotches
10 Best - Single Malt Scotches10 Best - Single Malt Scotches
10 Best - Single Malt Scotches
 
3D Cameras - Evolution (Films to 3D) and Road Ahead
3D Cameras - Evolution (Films to 3D) and Road Ahead3D Cameras - Evolution (Films to 3D) and Road Ahead
3D Cameras - Evolution (Films to 3D) and Road Ahead
 
IIM A PGPX - 6th Batch - Snapshot
IIM A PGPX - 6th Batch - SnapshotIIM A PGPX - 6th Batch - Snapshot
IIM A PGPX - 6th Batch - Snapshot
 
PGPX - One Day Theatre - Lessons
PGPX - One Day Theatre -  Lessons PGPX - One Day Theatre -  Lessons
PGPX - One Day Theatre - Lessons
 
TVS Suzuki JV Split - Analysis on Corp Governance
TVS Suzuki JV Split - Analysis on Corp GovernanceTVS Suzuki JV Split - Analysis on Corp Governance
TVS Suzuki JV Split - Analysis on Corp Governance
 
Ani's Small World - 35 Revolutions Around The Sun
Ani's Small World  - 35 Revolutions Around The SunAni's Small World  - 35 Revolutions Around The Sun
Ani's Small World - 35 Revolutions Around The Sun
 
Saint Joan - Leadership Lessons
Saint Joan - Leadership LessonsSaint Joan - Leadership Lessons
Saint Joan - Leadership Lessons
 
Containerization and India - Status
Containerization and India - StatusContainerization and India - Status
Containerization and India - Status
 
Capital Account Convertibility and India - Status
Capital Account Convertibility and India - StatusCapital Account Convertibility and India - Status
Capital Account Convertibility and India - Status
 
The State of 3PL Industry
The State of 3PL IndustryThe State of 3PL Industry
The State of 3PL Industry
 
Exploring Consumers Mind and Heart - Apartment-Wallahs
Exploring Consumers Mind and Heart  - Apartment-WallahsExploring Consumers Mind and Heart  - Apartment-Wallahs
Exploring Consumers Mind and Heart - Apartment-Wallahs
 
How Will You Measure Your Life
How Will You Measure Your LifeHow Will You Measure Your Life
How Will You Measure Your Life
 
IIMA PGPX - FT Ranking Communique
IIMA PGPX - FT Ranking CommuniqueIIMA PGPX - FT Ranking Communique
IIMA PGPX - FT Ranking Communique
 
IIMA PGPX - Introduction
IIMA PGPX - IntroductionIIMA PGPX - Introduction
IIMA PGPX - Introduction
 
Leadership Tips from Jack Welch - Summary by Ani
Leadership Tips from Jack Welch  - Summary by AniLeadership Tips from Jack Welch  - Summary by Ani
Leadership Tips from Jack Welch - Summary by Ani
 
The Long Tail - A Summary by Ani
The Long Tail  - A Summary by AniThe Long Tail  - A Summary by Ani
The Long Tail - A Summary by Ani
 
Scrum and Agile SDLC 101
Scrum and Agile SDLC 101Scrum and Agile SDLC 101
Scrum and Agile SDLC 101
 
India-aah
India-aahIndia-aah
India-aah
 

Recently uploaded

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

EJB 3.0 and J2EE

  • 1. Understanding EJB By: Asha Pathik Aniruddha Ray
  • 2. Saastha Infotech Agenda • Overview and Basic Concepts – What is EJB? – When to use EJB – Containers – Evolution of EJB • EJB Components – Types of Enterprise Beans – Session Beans – Entity Beans – Message-driven Beans • Creating an EJB • Summary 2
  • 3. Saastha Infotech Overview and Basic concepts What is EJB? 3
  • 4. Saastha Infotech What is EJB ( Enterprise Java Beans )? • EJB is the J2EE standard for developing and deploying server-side distributed components in java • It defines a contract between components and application servers that enables any component to run on any compliant server – it is the ubiquitous industry standard – portability is possible – rapid application development – physically, EJB is two things • a specification • a set of Java interfaces 4
  • 5. Saastha Infotech Overview and Basic concepts When to use EJB 5
  • 6. Saastha Infotech When to use EJB • For large scale applications where resources and data are distributed. • When the application is running on different servers at many locations. • Where scalability is critical. • Where transactions are required to ensure data integrity • When a variety of clients need to handled 6
  • 7. Saastha Infotech Overview and Basic concepts Evolution of Enterprise JavaBeans 7
  • 8. Saastha Infotech Evolution of Enterprise Java Beans – Part 1 • EJB release 1.0 focused on the following aspects: – defined the distinct “EJB roles” that are assumed by the component architecture – defined the client view of enterprise beans – defined the developer’s view of enterprise beans – defined the responsibilities of EJB Container provider and Server Provider – defined the format of ejb.jar file, EJB’s unit of deployment • EJB release 1.1 augmented these with following: – provided better support for application assembly and deployment – specified in greater detail the responsibilities of the individual EJB roles 8
  • 9. Saastha Infotech Evolution of Enterprise Java Beans – Part 2 • EJB release 2.0 focused on the following aspects: – defined message-driven bean and the integration with the JMS – provided local client view and support for efficient, lightweight access to EJB from local clients – defined new architecture for container persistence – support for management of relationships among entity beans – declarative query syntax for finder and select methods for entity beans with container-managed persistence – support for additional methods in home interface – support for run-as security identity – provided for network interoperability among servers 9
  • 10. Saastha Infotech Evolution of Enterprise Java Beans – Part 3 • EJB release 2.1 focused on the following aspects: – enabling enterprise beans to implement and utilize web services – providing a container-managed timer services – enhancing EJB QL with additional ORDER BY and aggregate operators – enhancing the message-driven bean component type to other messaging types • The EJB release 3.0 is focused on a simplification of the Enterprise JavaBeans architecture from the developer’s point of view. 10
  • 11. Saastha Infotech Overview and Basic concepts Containers 11
  • 12. Saastha Infotech Containers • Are the interface between a component and low-level platform-specific functionality that supports the component – components are simple set of programs that are capable of performing a particular business logic • Provide configurable settings : like data accessibility • Manages non-configurable settings like enterprise bean and servlet life cycles, database connection resource pooling, data persistence etc. • Before a J2EE component can be executed, it must be assembled into J2EE application and deployed into its container 12
  • 15. Saastha Infotech Session Bean : Concepts • A Session Bean is non-persistent object that implements some business logic. – private to one client connection – represents an interactive session – not recoverable after system crash or shutdown! – when client terminates, bean terminates i.e. no longer active • A Stateful Session Bean has Conversational State – activation/ passivation of a Bean is possible – E.g. items reviewed in a session at some sites. • A Stateless Session Bean has no Conversational State – no activation or passivation – pooling of stateless Session Beans by the container – very efficient – E.g. computing value using a formula. 15
  • 16. Saastha Infotech Stateful Session Bean : Part(1) Conversational Bean • Consists of attributes and referenced objects : – all non-transient attributes of the Bean – referenced data in the database – open connections to network – references to other Beans – etc. • Exists during one client session • A Conversation State is not persistent and is not automatically rolled back when a transaction fails! 16
  • 17. Saastha Infotech Stateful Session Bean : Part(2) • Passivation: – container serializes Bean instance and saves it to disk – preparation for Passivation is done with the method ejbPassivate: • close all existing connections • resolve all external references • Activation: – de-serialize Bean instance from disk – afterwards, ejbActivate method is invoked to: • re-establish external references • re-establish connections • If non-serializable objects are part of the state, these methods must be implemented in the Bean class 17
  • 18. Saastha Infotech Stateful Session Bean : Life Cycle 18
  • 19. Saastha Infotech Stateless Session Bean • All instances are equivalent • Private to one client only during one call • Pooled while not in use 19
  • 21. Saastha Infotech Entity Bean : Concept • An Entity Bean represents an object-oriented view of some entities stored in a persistent, crash-resistant storage (usually a relational database) – persistent and transient (modifier transient) attributes are allowed, but only persistent attributes will be saved in database. – each entity bean typically has an underlying table in a RDBMS( business data), and each instance of the bean corresponds to a row in that table. – transactional and recoverable on a server crash. • Shared among multiple clients ( no per-client state) • Primary Key : a unique attribute of bean or a serializable class (Primary Key Class) with one or more attributes • Two Beans with same Home Interface and same Primary Key are regarded as identical ( Bean Identity) 21
  • 22. Saastha Infotech Persistence Management • Bean-Managed Persistence (BMP) : any java-accessible data storage is possible – implements persistence mechanisms in ejbLoad resp. ejbStore – implements ejbActivate, ejbPassivate and ejbRemove – ejbCreate must return a ‘real’ primary key ( e.g. return pk;) • Container-Managed Persistence (CMP) : Container controls access to (usually) a relational database – empty implementation of ejbLoad, ejbStore, ejbActivate, ejbPassivate and ejbRemove – ejbCreate returns ‘null’ as primary key ( return null) – Object-Relational Mapping between Bean attributes and database entries ( Vendor –specific) – more details later 22
  • 23. Saastha Infotech Primary Key • A Primary Key of an Entity Bean consists of one or more persistent Bean attributes – values of primary key attributes must be unique for a Bean instance – primary key attributes must be serializable • The primary key class … – is a serializable class with one or several attributes which ( together) acts as primary key of an Entity Bean • one can use e.g. Long or String for single primary key attributes or specific classes • all primary key attributes must be persistent Bean attributes – must be declared in the Bean’s Deployment Descriptor 23
  • 24. Saastha Infotech Activation and Passivation • The EJB Container can passivate unused Entity Beans – ejbPassivate is invoked – used resources ( e.g. database connections, references to other Beans etc. ) are freed – bean instance is pooled • The Bean is activated when used again – an instance of this Bean is taken from the pool – ejbActivate is invoked – needed resources are occupied ( e.g. database connections are re-established) 24
  • 25. Saastha Infotech Entity Bean : Life Cycle 25
  • 27. Saastha Infotech Message-Driven Bean – Concepts (1) • Like a Stateless Session Bean, a Message-driven Bean only provides a piece of business logic without state management ( similar life cycle) • A Message-driven bean must implement the interfaces javax.ejb.MessageDrivenBean and javax.ejb.MessageListener – MessageListener declares a method public void onMessage(Message msg) which will be invoked when message arrives • A Message-driven Bean has no client-visible interfaces 27
  • 28. Saastha Infotech Message-Driven Bean – Concepts (2) • A Message-driven bean is assigned to a JMS destination by means of the Deployment Descriptor element – message-driven destination • The bean is invoked by the container, when a JMS message to this destination arrives 28
  • 29. Saastha Infotech Message-Driven Bean – Concepts (3) • A message driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously • It acts a JMS listener, which is similar to an event listener except that it receives messages instead of events • The messages can be sent to any J2EE component or a non-J2EE system using JMS • It retains no data or conversational state 29
  • 30. Saastha Infotech Contents of an EJB • Interfaces: The remote and home interface for remote access. Local and local home accesses for local access. • Enterprise bean class: Implements the methods defined in the above interfaces. • Deployment descriptor: An XML file that specifies information about the bean such as its type, transaction attributes, etc. • Helper classes: non-bean classes needed by the enterprise bean class such as utility and exception classes. 30