01/17/2025 1
Enterprise Java Beans
Dr M.Rani
Reddy
01/17/2025 2
J2EE Technology Architecture
Server
platform
JTS JMAPI JNDI JMS JDBC
JAXP JAAS …
Enterprise Java Beans Components
Java Server
pages
Servlets
Application clients Web clients
IIOP,
others
html
01/17/2025 3
Enterprise Java Bean(EJB)
An enterprise bean is a server-side
component that contains the business
logic of an application. At runtime, the
application clients execute the business
logic by invoking the enterprise bean's
methods.
Main goal of Enterprise Java Bean (EJB)
architecture is to free the application
developer from having to deal with the
system level aspects of an application. This
allows the bean developer to focus solely
on the logic of the application.
01/17/2025 4
Roles in EJB Development
Bean developer: Develops bean component.
Application assembler: composes EJBs to form
applications
Deployer: deploys EJB applications within an
operation environment.
System administrator: Configures and administers
the EJB computing and networking infrastructure.
EJB Container Provider and EJB server provider:
Vendors specializing in low level services such as
transactions and application mgt.
01/17/2025 5
Enterprise Java Bean (EJB)
Deployable unit of code.
At run-time, an enterprise bean resides in
an EJB container.
An EJB container provides the deployment
environment and runtime environment for
enterprise beans including services such as
security, transaction, deployment,
concurrency etc.
Process of installing an EJB in a container is
called EJB deployment.
01/17/2025 6
Enterprise Application with
many EJBs
WebClient
ApplClient
EJB1
EJB2
EJB3
EJB4
EJB5
EJB6
Lets consider a shopping front application and figure out the
possible components (EJBs)
01/17/2025 7
Deployment with Multiple
EJB Clients
Web
Container1
Deploys:
WebApp1
EJB
Container1
Deploys :
EJB1,EJB2,EJB3
Client
Container1
Deploys :
Client1
EJB
Container2
Deploys :
EJB4
Client
Container3
Deploys :
EJB5,EJB6
01/17/2025 8
Business Entities, Processes
and Rules
EJB Applications organize business rules
into components.
Components typically represent a business
entity or business process.
Entity: is an object representing some
information maintained in the enterprise.
Has a “state” which may be persistent.
Example: Customer, Order, Employee,
Relationships are defined among the
entities: dependencies.
01/17/2025 9
Process
Is an object that typically encapsulates an
interaction of a user with business entities.
A process typically updated and changes the state
of the entities.
A business process may have its own state which
may exist only for the duration of the process; at
the completion of the process the state ceases to
exist.
Process state may be transient or persistent.
States ate transient for conversational processes
and persistent for collaborative processes.
01/17/2025 10
Rules
Rules that apply to the state of an
entity should be implemented in the
component that represents the
entity.
Rules that apply to the processes
should be implemented in the
component that represents the
processes.
01/17/2025 11
EJB Types
There are three types of EJBs:
Entity, session and message-driven
The syntax of the session bean and entity
bean client-view API is almost identical.
But they have different life cycle, different
persistence management, etc.
EJBs can be stateless and stateful beans.
01/17/2025 12
Life Cycle Differences
Session Bean
Object state:
Maintained by container
Object Sharing:
No sharing: per client
State Externalization:
State is inaccessible to other
programs
Transactions:
Not recoverable
Failure Recovery:
Not guaranteed to survive
failures
Entity Bean
Maintained by DB
Shared by multiple client
Accessible to other programs
State changed transactionally and is
recoverable.
Survives failures and restored when the
container restarts.
01/17/2025 13
Choosing Entity or Session
Bean
Entity (business entity) is typically implemented as
entity bean or a dependent object of an entity
bean.
Conversational (business) process as a session
bean.
Collaborative bean as an entity bean.
Any process that requires persistence is
implemented as an entity bean.
When exposure to other applications are not
needed for an entity or process (local/private
process) then they are implemented as bean
dependent objects.
01/17/2025 14
Parts of EJB
EJB class that implements the business
methods and life cycle methods; uses other
helper classes and libraries to implement.
Client-view API: consists of EJB home
interface and remote interface.
 Home interface: controls life cycle : create,
remove, find methods
 Remote interface: to invoke the EJB object
methods
01/17/2025 15
Parts of EJB (contd.)
Deployment Descriptor: XML document for
bean assembler and deployer;
 A declaration about EJB environment needed
for customizing the bean to the operating
environment.
Container Runtime services include:
transactions, security,distribution,load
balancing, multithreading, persistence,
failure recovery, resource pooling, state
management, clustering..
01/17/2025 16
Enterprise Bean Parts
<<Home Interface>>
AccountHome
create()
find()
remove()
<<Remote Interface>>
Account
debit()
credit()
getBalance()
<<Enterrpise Bean class>
AccountBean
ejbCreate()
ejbFind()
ejbRemove()
debit()
credit()
getBalance()
Deployment Descriptor
name = AccountEJB
class = AccountBean
home = AccountHome
remote = Account
type = Entity
transaction = required
…..
01/17/2025 17
AccountHome Interface
port java.rmi.RemoteException;
port javax.ejb.CreateException;
port javax.ejb.FinderException;
port java.util.Collection;
blic interface AccountHome extends javax.ejb.EJBHome {
eate methods
ount create (String lastName, String firstName) throws RemoteException,
CreateException, BadNameException;
ount create (String lastName) throws RemoteException, CreateException;
nd methods
ount findByPrimaryKey (AccountKey primaryKey) throws RemoteException,
FinderException;
ection findInActive(Date sinceWhen)
throws RemoteException, FinderException, BadDateException;
01/17/2025 18
Account Interface
import java.rmi.RemoteException;
public interface Account extends javax.ejb.EJBObject {
BigDecimal getBalance() throws RemoteException;
void credit(BiGDecimal amount) throws RemoteException;
Void debit(BigDecimal amount) throws RemoteException,
InSufficientFundsException;
}
01/17/2025 19
B.Ramamurthy
AccountBean class
ublic class AccountBean implements javax.ejb.EntityBean {
/ life cycle methods from home interface
ublic AccountKey ejbCreate (String latName, String firstName) throws … {…}
ublic AccountKey ejbCreate(String lastName) throws …{…}
ublic AccountKey ejbFindByPrimaryKey(AccountKey primarykey)… {…}
ublic Collection ejbFindInactive( Data sinecWhen).. {…}
/ business methods from remote interface
ublic BigDecimal getBalance() {….}
ublic void credit(BigDecimal amt) {…}
ublic void debit(BigDecimal amt) throws InsufficientFundException {….}
/ container callbacks from EntityBean container
ublic ejbRemove( ) throws RemoveException{ …}
ublic void setEntityContext(EntityContext ec) {…}
ublic unsetEntityContext(EntityContext ec) {…}
ublic void ejbActivate() {…}
ublic void ejbLoad() {….}
ublic void ejbStore() {….}
01/17/2025 20
Deployment Descriptor
…
<entity-bean>
<ejb-name>AccountEJB</ejb-name>
<home>com.wombat.AccopuntHome</home>
<remote>com.wombat.Account</remote>
<ejb-class>com.wombat.AccountBean</ejb-class>
<persistence-type>Bean<persistence-type>
<primary-key-class>com.wombat.AccountKey</primary-key-class>
</entity-bean>
…
<container-transaction>
<method>
<ejb-name>AcoountEJB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>required</trans-attribute>
</container-transaction>
…

More Related Content

PPT
J2EEFeb11 (1).ppt
PPT
J2EEFeb11.ppt
PPT
ADVANCED JAVA MODULE I & II.ppt
PPT
Aravind vinnakota ejb_architecture
PDF
Introcution to EJB
PPTX
The Latest in Enterprise JavaBeans Technology
PDF
Ejb intro
PPT
EJBDetailsFeb25.ppt
J2EEFeb11 (1).ppt
J2EEFeb11.ppt
ADVANCED JAVA MODULE I & II.ppt
Aravind vinnakota ejb_architecture
Introcution to EJB
The Latest in Enterprise JavaBeans Technology
Ejb intro
EJBDetailsFeb25.ppt

Similar to EJB.ppthckhkhohjpfuysfzhxjvkgur6eydgdcjjggjj (20)

PPT
PPT
Unite5-EJB-2019.ppt
PDF
Ejb notes
PPT
Session 3 Tp3
PPT
PDF
Ejb intro
PPT
Ejb training institute in navi-mumbai
PDF
Enterprise Java Beans - EJB
PPT
Ejb (1)
PPTX
PDF
Enterprise Javabeans 31 Sixth Edition Andrew Lee Rubinger Bill Burke
PPT
ejb.ppt java lecture notes enterprise java
PPTX
UNIT 4.pptx
PDF
EJB 3.0 - Yet Another Introduction
PPTX
EJB3 Basics
PDF
Ejb - september 2006
PPT
Enterprise java beans(ejb)
PPT
Enterprise Java Beans( E)
PPT
Enterprise java beans(ejb) Update 2
Unite5-EJB-2019.ppt
Ejb notes
Session 3 Tp3
Ejb intro
Ejb training institute in navi-mumbai
Enterprise Java Beans - EJB
Ejb (1)
Enterprise Javabeans 31 Sixth Edition Andrew Lee Rubinger Bill Burke
ejb.ppt java lecture notes enterprise java
UNIT 4.pptx
EJB 3.0 - Yet Another Introduction
EJB3 Basics
Ejb - september 2006
Enterprise java beans(ejb)
Enterprise Java Beans( E)
Enterprise java beans(ejb) Update 2
Ad

More from rani marri (20)

PPTX
RESTful Web Services.pptxbnbjmgbjbvvhvhj
PPT
ch11 jrtrtgrrhwddewwfetbbfdrhwefegtrhgtgr
PPTX
express.js.pptxgghhhhhhnnbvcdssazxvuyiknvc
PPTX
NagiOs.pptxhjkgfddssddfccgghuikjhgvccvvhjj
PPTX
Lecture7.pptxhfjgjgjghcgzgzfzfzvzgxhchchc
PPTX
git.ppt.pptx power point presentation got Google internet
PPTX
Containers Orchestration using kubernates.pptx
PPTX
JSP.pptx programming guide for beginners and experts
PPT
CSC128_Part_1_WrapperClassesAndStrings_CenBNcj.ppt
PPT
nodejs tutorial foor free download from academia
PPTX
NAAC PPT M.B.A.pptx
PPTX
must.pptx
PPTX
node.js.pptx
PPTX
oops with java modules iii & iv.pptx
PPT
oops with java modules i & ii.ppt
PPTX
software engineering modules iii & iv.pptx
PPTX
software engineering module i & ii.pptx
PPT
ADVANCED JAVA MODULE III & IV.ppt
PPTX
data structures module III & IV.pptx
PPTX
data structures module I & II.pptx
RESTful Web Services.pptxbnbjmgbjbvvhvhj
ch11 jrtrtgrrhwddewwfetbbfdrhwefegtrhgtgr
express.js.pptxgghhhhhhnnbvcdssazxvuyiknvc
NagiOs.pptxhjkgfddssddfccgghuikjhgvccvvhjj
Lecture7.pptxhfjgjgjghcgzgzfzfzvzgxhchchc
git.ppt.pptx power point presentation got Google internet
Containers Orchestration using kubernates.pptx
JSP.pptx programming guide for beginners and experts
CSC128_Part_1_WrapperClassesAndStrings_CenBNcj.ppt
nodejs tutorial foor free download from academia
NAAC PPT M.B.A.pptx
must.pptx
node.js.pptx
oops with java modules iii & iv.pptx
oops with java modules i & ii.ppt
software engineering modules iii & iv.pptx
software engineering module i & ii.pptx
ADVANCED JAVA MODULE III & IV.ppt
data structures module III & IV.pptx
data structures module I & II.pptx
Ad

Recently uploaded (20)

PDF
Timeless Interiors by PEE VEE INTERIORS
PDF
analisis snsistem etnga ahrfahfffffffffffffffffffff
PPTX
supertech supernova queen tower at noida
PDF
321 LIBRARY DESIGN.pdf43354445t6556t5656
PPTX
URBAN FINANCEnhynhynnnytnynnnynynyynynynyn
PPT
EthicsNotesSTUDENTCOPYfghhnmncssssx sjsjsj
PDF
Social Media USAGE .............................................................
PPTX
22CDH01-V3-UNIT III-UX-UI for Immersive Design
PPT
aksharma-dfs.pptgfgfgdfgdgdfgdfgdgdrgdgdgdgdgdgadgdgd
PPT
416170345656655446879265596558865588.ppt
PPTX
ENG4-Q2-W5-PPT (1).pptx nhdedhhehejjedheh
PPTX
Project_Presentation Bitcoin Price Prediction
PPTX
UNIT III - GRAPHICS AND AUDIO FOR MOBILE
PDF
IARG - ICTC ANALOG RESEARCH GROUP - GROUP 1 - CHAPTER 2.pdf
PPTX
ACL English Introductionadsfsfadf 20200612.pptx
PPTX
8086.pptx microprocessor and microcontroller
PDF
This presentation is made for a design foundation class at Avantika Universit...
PPTX
Bitcoin predictor project presentation
PPTX
UNIT II - UID FOR MOBILE GAMES[INTRODUCTION TO MOBILE GAME DESIGN]
PPTX
Necrosgwjskdnbsjdmdndmkdndndnmdndndkdmdndkdkndmdmis.pptx
Timeless Interiors by PEE VEE INTERIORS
analisis snsistem etnga ahrfahfffffffffffffffffffff
supertech supernova queen tower at noida
321 LIBRARY DESIGN.pdf43354445t6556t5656
URBAN FINANCEnhynhynnnytnynnnynynyynynynyn
EthicsNotesSTUDENTCOPYfghhnmncssssx sjsjsj
Social Media USAGE .............................................................
22CDH01-V3-UNIT III-UX-UI for Immersive Design
aksharma-dfs.pptgfgfgdfgdgdfgdfgdgdrgdgdgdgdgdgadgdgd
416170345656655446879265596558865588.ppt
ENG4-Q2-W5-PPT (1).pptx nhdedhhehejjedheh
Project_Presentation Bitcoin Price Prediction
UNIT III - GRAPHICS AND AUDIO FOR MOBILE
IARG - ICTC ANALOG RESEARCH GROUP - GROUP 1 - CHAPTER 2.pdf
ACL English Introductionadsfsfadf 20200612.pptx
8086.pptx microprocessor and microcontroller
This presentation is made for a design foundation class at Avantika Universit...
Bitcoin predictor project presentation
UNIT II - UID FOR MOBILE GAMES[INTRODUCTION TO MOBILE GAME DESIGN]
Necrosgwjskdnbsjdmdndmkdndndnmdndndkdmdndkdkndmdmis.pptx

EJB.ppthckhkhohjpfuysfzhxjvkgur6eydgdcjjggjj

  • 1. 01/17/2025 1 Enterprise Java Beans Dr M.Rani Reddy
  • 2. 01/17/2025 2 J2EE Technology Architecture Server platform JTS JMAPI JNDI JMS JDBC JAXP JAAS … Enterprise Java Beans Components Java Server pages Servlets Application clients Web clients IIOP, others html
  • 3. 01/17/2025 3 Enterprise Java Bean(EJB) An enterprise bean is a server-side component that contains the business logic of an application. At runtime, the application clients execute the business logic by invoking the enterprise bean's methods. Main goal of Enterprise Java Bean (EJB) architecture is to free the application developer from having to deal with the system level aspects of an application. This allows the bean developer to focus solely on the logic of the application.
  • 4. 01/17/2025 4 Roles in EJB Development Bean developer: Develops bean component. Application assembler: composes EJBs to form applications Deployer: deploys EJB applications within an operation environment. System administrator: Configures and administers the EJB computing and networking infrastructure. EJB Container Provider and EJB server provider: Vendors specializing in low level services such as transactions and application mgt.
  • 5. 01/17/2025 5 Enterprise Java Bean (EJB) Deployable unit of code. At run-time, an enterprise bean resides in an EJB container. An EJB container provides the deployment environment and runtime environment for enterprise beans including services such as security, transaction, deployment, concurrency etc. Process of installing an EJB in a container is called EJB deployment.
  • 6. 01/17/2025 6 Enterprise Application with many EJBs WebClient ApplClient EJB1 EJB2 EJB3 EJB4 EJB5 EJB6 Lets consider a shopping front application and figure out the possible components (EJBs)
  • 7. 01/17/2025 7 Deployment with Multiple EJB Clients Web Container1 Deploys: WebApp1 EJB Container1 Deploys : EJB1,EJB2,EJB3 Client Container1 Deploys : Client1 EJB Container2 Deploys : EJB4 Client Container3 Deploys : EJB5,EJB6
  • 8. 01/17/2025 8 Business Entities, Processes and Rules EJB Applications organize business rules into components. Components typically represent a business entity or business process. Entity: is an object representing some information maintained in the enterprise. Has a “state” which may be persistent. Example: Customer, Order, Employee, Relationships are defined among the entities: dependencies.
  • 9. 01/17/2025 9 Process Is an object that typically encapsulates an interaction of a user with business entities. A process typically updated and changes the state of the entities. A business process may have its own state which may exist only for the duration of the process; at the completion of the process the state ceases to exist. Process state may be transient or persistent. States ate transient for conversational processes and persistent for collaborative processes.
  • 10. 01/17/2025 10 Rules Rules that apply to the state of an entity should be implemented in the component that represents the entity. Rules that apply to the processes should be implemented in the component that represents the processes.
  • 11. 01/17/2025 11 EJB Types There are three types of EJBs: Entity, session and message-driven The syntax of the session bean and entity bean client-view API is almost identical. But they have different life cycle, different persistence management, etc. EJBs can be stateless and stateful beans.
  • 12. 01/17/2025 12 Life Cycle Differences Session Bean Object state: Maintained by container Object Sharing: No sharing: per client State Externalization: State is inaccessible to other programs Transactions: Not recoverable Failure Recovery: Not guaranteed to survive failures Entity Bean Maintained by DB Shared by multiple client Accessible to other programs State changed transactionally and is recoverable. Survives failures and restored when the container restarts.
  • 13. 01/17/2025 13 Choosing Entity or Session Bean Entity (business entity) is typically implemented as entity bean or a dependent object of an entity bean. Conversational (business) process as a session bean. Collaborative bean as an entity bean. Any process that requires persistence is implemented as an entity bean. When exposure to other applications are not needed for an entity or process (local/private process) then they are implemented as bean dependent objects.
  • 14. 01/17/2025 14 Parts of EJB EJB class that implements the business methods and life cycle methods; uses other helper classes and libraries to implement. Client-view API: consists of EJB home interface and remote interface.  Home interface: controls life cycle : create, remove, find methods  Remote interface: to invoke the EJB object methods
  • 15. 01/17/2025 15 Parts of EJB (contd.) Deployment Descriptor: XML document for bean assembler and deployer;  A declaration about EJB environment needed for customizing the bean to the operating environment. Container Runtime services include: transactions, security,distribution,load balancing, multithreading, persistence, failure recovery, resource pooling, state management, clustering..
  • 16. 01/17/2025 16 Enterprise Bean Parts <<Home Interface>> AccountHome create() find() remove() <<Remote Interface>> Account debit() credit() getBalance() <<Enterrpise Bean class> AccountBean ejbCreate() ejbFind() ejbRemove() debit() credit() getBalance() Deployment Descriptor name = AccountEJB class = AccountBean home = AccountHome remote = Account type = Entity transaction = required …..
  • 17. 01/17/2025 17 AccountHome Interface port java.rmi.RemoteException; port javax.ejb.CreateException; port javax.ejb.FinderException; port java.util.Collection; blic interface AccountHome extends javax.ejb.EJBHome { eate methods ount create (String lastName, String firstName) throws RemoteException, CreateException, BadNameException; ount create (String lastName) throws RemoteException, CreateException; nd methods ount findByPrimaryKey (AccountKey primaryKey) throws RemoteException, FinderException; ection findInActive(Date sinceWhen) throws RemoteException, FinderException, BadDateException;
  • 18. 01/17/2025 18 Account Interface import java.rmi.RemoteException; public interface Account extends javax.ejb.EJBObject { BigDecimal getBalance() throws RemoteException; void credit(BiGDecimal amount) throws RemoteException; Void debit(BigDecimal amount) throws RemoteException, InSufficientFundsException; }
  • 19. 01/17/2025 19 B.Ramamurthy AccountBean class ublic class AccountBean implements javax.ejb.EntityBean { / life cycle methods from home interface ublic AccountKey ejbCreate (String latName, String firstName) throws … {…} ublic AccountKey ejbCreate(String lastName) throws …{…} ublic AccountKey ejbFindByPrimaryKey(AccountKey primarykey)… {…} ublic Collection ejbFindInactive( Data sinecWhen).. {…} / business methods from remote interface ublic BigDecimal getBalance() {….} ublic void credit(BigDecimal amt) {…} ublic void debit(BigDecimal amt) throws InsufficientFundException {….} / container callbacks from EntityBean container ublic ejbRemove( ) throws RemoveException{ …} ublic void setEntityContext(EntityContext ec) {…} ublic unsetEntityContext(EntityContext ec) {…} ublic void ejbActivate() {…} ublic void ejbLoad() {….} ublic void ejbStore() {….}