enterprise java beans (ejb)
DESCRIPTION
Enterprise Java Beans (EJB). Enterprise Java Beans EJB Architecture Types of EJB. Where they fit in a system. Using EJB’s. Clients. Enterprise JavaBeans Architecture. The EJB architecture specifies the responsibilities and interactions among EJB entities. EJB Servers. EJB Containers. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/1.jpg)
Enterprise Java Beans (EJB)
![Page 2: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/2.jpg)
• Enterprise Java Beans
• EJB Architecture
• Types of EJB.
![Page 3: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/3.jpg)
Where they fit in a system
![Page 4: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/4.jpg)
Using EJB’s
![Page 5: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/5.jpg)
Enterprise JavaBeans Architecture
The EJB architecture specifies the responsibilities and interactions among EJB entities
EJB Servers
Enterprise Beans EJB Clients
EJB ServerEJB Server
EJB Container
Enterprise Bean
Enterprise Bean
EJB Containers
Clients
![Page 6: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/6.jpg)
EJB ServerEJB Server
EJB Server
The EJB Server provides system services and manages resources
– Process and thread management
– System resources management
– Database connection pooling
– Management API
Provides a Runtime EnvironmentProvides a Runtime Environment
![Page 7: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/7.jpg)
EJB ServerEJB Server
EJB Container
EJB Container
Hosts the Enterprise JavaBeans Provides services to Enterprise JavaBeans
– Naming
– Life cycle management
– Persistence (state management)
– Transaction Management
– Security
Provides a Run-time Environment for an Enterprise Bean
Provides a Run-time Environment for an Enterprise Bean
![Page 8: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/8.jpg)
Enterprise Beans A specialized Java class where the real business logic lives
– May be developer-written or tool-generated Distributed over a network Transactional Secure Server vendors provide tools that automatically generate
distribution, transaction and security behavior
EJB ServerEJB Server
EJB Container
Enterprise Bean
Enterprise Bean
![Page 9: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/9.jpg)
EJB Clients
Client access is controlled by the container in which the enterprise Bean is deployed
Clients locates an Enterprise JavaBean through Java Naming and Directory Interface (JNDI)
RMI is the standard method for accessing a bean over a network
EJB ServerEJB Server
EJB Container
Enterprise Bean
Enterprise Bean
Clients
![Page 10: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/10.jpg)
JavaBeans vs EJB
Enterprise JavaBeans is a framework for building and deploying server-side Java components
JavaBeans is a framework for client-side Java components
Conceptually related because both are components The specifications do not build on each other.
![Page 11: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/11.jpg)
Three kinds of EJB’s
• Session– associate client information with a specific
client– both stateless and stateful versions
• Entity– groups associated information in an abstraction
that provides transaction support• Message Bean - rarely used, hardly supported
![Page 12: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/12.jpg)
What is a Session Bean?
• Represents a single Client inside the J2EE server
• one client at a time/ not persistent
• when the client terminates, the session bean is disassociated from the client
• There are two types: Stateful and Stateless...
![Page 13: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/13.jpg)
Stateful
• These represent a set of interactions between client and server.– Example: shopping cart
• Saves information over several method invocations.
• There is a lot of overhead associated with using stateful beans
![Page 14: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/14.jpg)
Stateless
• A stateless bean does not save information between method calls.
• Limited application• Little overhead
– multiple clients can use the same bean instance without alteration
• Example: fetch from a read-only database or send a confirmation email for an order
![Page 15: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/15.jpg)
Entity Beans
• Associates pieces of information in a group
• Accessed by multiple clients at a time
• Persistent and Serializable
• The container loads and stores the entity beans in the database
• These are more similar to regular beans
![Page 16: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/16.jpg)
Persistence in Entity Beans
• Container Managed Persistence (CMP)– the container controls when the bean is read
from or written to the database• Bean Managed Persistence (BMP)
– the bean’s implementation performs all of the SQL operations that loads, stores, and updates the bean’s data to or from the database.
– Bean is responsible for connection allocation to the database
![Page 17: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/17.jpg)
Comparing Session and Entity Beans
Mandatory for EJB 1.0 Represents a specific
client(1 instance per client)
Short-lived Transient Can be any Java class May be transactional Business Logic Beans
Optional for EJB 1.0 Represents underlying data
object or context
(clients share instance)
Long-lived Persistent Can be a class that maps to
persistent data (e.g., database)
Always transactional
Beans which represent data
Session BeansSession Beans Entity BeansEntity Beans
![Page 18: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/18.jpg)
Message Beans
• A message bean is an enterprise bean that allows J2EE applications to process messages asynchronously. It acts as a JMS(Java Messaging Services) message listener, which is similar to an event listener except that it receives messages instead of events.
• Many systems do not yet support JMS, message bean use is currently not widespread
![Page 19: Enterprise Java Beans (EJB)](https://reader036.vdocuments.site/reader036/viewer/2022062301/568133d8550346895d9ace43/html5/thumbnails/19.jpg)
THANKS