SlideShare una empresa de Scribd logo
1 de 24
5/27/2023 B.Ramamurthy 1
Enterprise Java Beans
Bina Ramamurthy
5/27/2023 B.Ramamurthy 2
Introduction
J2EE (Java2 Enterprise Edition) offers a
suite of software specification to design,
develop, assemble and deploy
enterprise applications.
It provides a distributed, component-
based, loosely coupled, reliable and
secure, platform independent and
responsive application environment.
5/27/2023 B.Ramamurthy 3
J2EE Technologies
Enterprise Java Bean Technology 2.0
JDBC API 2.0
Java Servlet Technology 2.3
Java Server Pages Technology 1.2
Java Messaging Service 1.0
Java Naming and Directory Interface 1.2
Java Transaction API 1.0
Java Mail API 1.2
Javabeans activation framework 1.0
Java API for XML Processing 1.1
Java Connector Architecture 1.0
Java Authentication and Authorization Service 1.0
Tools: deploytool (scripts etc.)
5/27/2023 B.Ramamurthy 4
Systems and Application
Integration
The J2EE APIs enable systems and
applications integration through the following:
 Unified application model across tiers with
enterprise beans
 Simplified response and request mechanism with
JSP pages and servlets
 Reliable security model with JAAS
 XML-based data interchange integration with JAXP
 Simplified interoperability with the J2EE Connector
Architecture
 Easy database connectivity with the JDBC API
 Enterprise application integration with message-
driven beans and JMS, JTA, and JNDI
5/27/2023 B.Ramamurthy 5
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
5/27/2023 B.Ramamurthy 6
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.
5/27/2023 B.Ramamurthy 7
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/27/2023 B.Ramamurthy 8
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.
5/27/2023 B.Ramamurthy 9
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)
5/27/2023 B.Ramamurthy 10
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
5/27/2023 B.Ramamurthy 11
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.
5/27/2023 B.Ramamurthy 12
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.
5/27/2023 B.Ramamurthy 13
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.
5/27/2023 B.Ramamurthy 14
EJB Types
There are three types of EJBs:
Entity, session and message-driven
We will discuss message-driven bean in a
separate discussion.
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.
5/27/2023 B.Ramamurthy 15
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.
5/27/2023 B.Ramamurthy 16
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.
5/27/2023 B.Ramamurthy 17
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
5/27/2023 B.Ramamurthy 18
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..
5/27/2023 B.Ramamurthy 19
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
…..
5/27/2023 B.Ramamurthy 20
AccountHome Interface
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import java.util.Collection;
public interface AccountHome extends javax.ejb.EJBHome {
//create methods
Account create (String lastName, String firstName) throws RemoteException,
CreateException, BadNameException;
Account create (String lastName) throws RemoteException, CreateException;
// find methods
Account findByPrimaryKey (AccountKey primaryKey) throws RemoteException,
FinderException;
Collection findInActive(Date sinceWhen)
throws RemoteException, FinderException, BadDateException;
5/27/2023 B.Ramamurthy 21
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;
}
5/27/2023 B.Ramamurthy 22
AccountBean class
public class AccountBean implements javax.ejb.EntityBean {
// life cycle methods from home interface
public AccountKey ejbCreate (String latName, String firstName) throws … {…
public AccountKey ejbCreate(String lastName) throws …{…}
public AccountKey ejbFindByPrimaryKey(AccountKey primarykey)… {…}
Public Collection ejbFindInactive( Data sinecWhen).. {…}
// business methods from remote interface
public BigDecimal getBalance() {….}
public void credit(BigDecimal amt) {…}
Public void debit(BigDecimal amt) throws InsufficientFundException {….}
// container callbacks from EntityBean container
public ejbRemove( ) throws RemoveException{ …}
public void setEntityContext(EntityContext ec) {…}
public unsetEntityContext(EntityContext ec) {…}
public void ejbActivate() {…}
public void ejbLoad() {….}
public void ejbStore() {….}
}
5/27/2023 B.Ramamurthy 23
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>
5/27/2023 B.Ramamurthy 24
Summary
J2EE environment provides a framework for
bundling together the components into an
application and provide the applications
necessary common services such as
persistence, security, mail, naming and
directory service etc.
Next class we will look a complete running
example.
Browse through:
 http://java.sun.com/j2ee/faq.html
 http://java.sun.com/blueprints/guidelines/designing_en
terprise_applications_2e/index.html#chapters

Más contenido relacionado

Similar a J2EEFeb11.ppt (20)

Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
 
EJB.docx
EJB.docxEJB.docx
EJB.docx
 
EJB 2
EJB 2EJB 2
EJB 2
 
Ejb
EjbEjb
Ejb
 
JEE Programming - 02 The Containers
JEE Programming - 02 The ContainersJEE Programming - 02 The Containers
JEE Programming - 02 The Containers
 
Lec2 ecom fall16
Lec2 ecom fall16Lec2 ecom fall16
Lec2 ecom fall16
 
Session 2 Tp2
Session 2 Tp2Session 2 Tp2
Session 2 Tp2
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
 
Jsf
JsfJsf
Jsf
 
A dynamic application using jboss
A dynamic application using jbossA dynamic application using jboss
A dynamic application using jboss
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Java EE EJB Applications
Java EE EJB ApplicationsJava EE EJB Applications
Java EE EJB Applications
 
EJB3 Basics
EJB3 BasicsEJB3 Basics
EJB3 Basics
 
J2EE Architecture Explained
J2EE  Architecture ExplainedJ2EE  Architecture Explained
J2EE Architecture Explained
 
TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6
 
Skillwise EJB3.0 training
Skillwise EJB3.0 trainingSkillwise EJB3.0 training
Skillwise EJB3.0 training
 
JEE Course - EJB
JEE Course - EJBJEE Course - EJB
JEE Course - EJB
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 
TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5
 
Virtual classroom
Virtual classroomVirtual classroom
Virtual classroom
 

Más de KalsoomTahir2

Más de KalsoomTahir2 (20)

005813616.pdf
005813616.pdf005813616.pdf
005813616.pdf
 
009576860.pdf
009576860.pdf009576860.pdf
009576860.pdf
 
005813185.pdf
005813185.pdf005813185.pdf
005813185.pdf
 
HASH FUNCTIONS.pdf
HASH FUNCTIONS.pdfHASH FUNCTIONS.pdf
HASH FUNCTIONS.pdf
 
6. McCall's Model.pptx
6. McCall's Model.pptx6. McCall's Model.pptx
6. McCall's Model.pptx
 
ch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.pptch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.ppt
 
9223301.ppt
9223301.ppt9223301.ppt
9223301.ppt
 
11885558.ppt
11885558.ppt11885558.ppt
11885558.ppt
 
Indexing.ppt
Indexing.pptIndexing.ppt
Indexing.ppt
 
chap05-info366.ppt
chap05-info366.pptchap05-info366.ppt
chap05-info366.ppt
 
1650607.ppt
1650607.ppt1650607.ppt
1650607.ppt
 
005281271.pdf
005281271.pdf005281271.pdf
005281271.pdf
 
soa_and_jra.ppt
soa_and_jra.pptsoa_and_jra.ppt
soa_and_jra.ppt
 
ERP_Up_Down.ppt
ERP_Up_Down.pptERP_Up_Down.ppt
ERP_Up_Down.ppt
 
Topic1CourseIntroduction.ppt
Topic1CourseIntroduction.pptTopic1CourseIntroduction.ppt
Topic1CourseIntroduction.ppt
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.ppt
 
jan28EAI.ppt
jan28EAI.pptjan28EAI.ppt
jan28EAI.ppt
 
005428052.pdf
005428052.pdf005428052.pdf
005428052.pdf
 
jini-1.ppt
jini-1.pptjini-1.ppt
jini-1.ppt
 

Último

How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineCeline George
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxMadhavi Dharankar
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...HetalPathak10
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 

Último (20)

How to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command LineHow to Uninstall a Module in Odoo 17 Using Command Line
How to Uninstall a Module in Odoo 17 Using Command Line
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 

J2EEFeb11.ppt

  • 1. 5/27/2023 B.Ramamurthy 1 Enterprise Java Beans Bina Ramamurthy
  • 2. 5/27/2023 B.Ramamurthy 2 Introduction J2EE (Java2 Enterprise Edition) offers a suite of software specification to design, develop, assemble and deploy enterprise applications. It provides a distributed, component- based, loosely coupled, reliable and secure, platform independent and responsive application environment.
  • 3. 5/27/2023 B.Ramamurthy 3 J2EE Technologies Enterprise Java Bean Technology 2.0 JDBC API 2.0 Java Servlet Technology 2.3 Java Server Pages Technology 1.2 Java Messaging Service 1.0 Java Naming and Directory Interface 1.2 Java Transaction API 1.0 Java Mail API 1.2 Javabeans activation framework 1.0 Java API for XML Processing 1.1 Java Connector Architecture 1.0 Java Authentication and Authorization Service 1.0 Tools: deploytool (scripts etc.)
  • 4. 5/27/2023 B.Ramamurthy 4 Systems and Application Integration The J2EE APIs enable systems and applications integration through the following:  Unified application model across tiers with enterprise beans  Simplified response and request mechanism with JSP pages and servlets  Reliable security model with JAAS  XML-based data interchange integration with JAXP  Simplified interoperability with the J2EE Connector Architecture  Easy database connectivity with the JDBC API  Enterprise application integration with message- driven beans and JMS, JTA, and JNDI
  • 5. 5/27/2023 B.Ramamurthy 5 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
  • 6. 5/27/2023 B.Ramamurthy 6 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.
  • 7. 5/27/2023 B.Ramamurthy 7 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.
  • 8. 5/27/2023 B.Ramamurthy 8 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.
  • 9. 5/27/2023 B.Ramamurthy 9 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)
  • 10. 5/27/2023 B.Ramamurthy 10 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
  • 11. 5/27/2023 B.Ramamurthy 11 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.
  • 12. 5/27/2023 B.Ramamurthy 12 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.
  • 13. 5/27/2023 B.Ramamurthy 13 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.
  • 14. 5/27/2023 B.Ramamurthy 14 EJB Types There are three types of EJBs: Entity, session and message-driven We will discuss message-driven bean in a separate discussion. 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.
  • 15. 5/27/2023 B.Ramamurthy 15 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.
  • 16. 5/27/2023 B.Ramamurthy 16 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.
  • 17. 5/27/2023 B.Ramamurthy 17 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
  • 18. 5/27/2023 B.Ramamurthy 18 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..
  • 19. 5/27/2023 B.Ramamurthy 19 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 …..
  • 20. 5/27/2023 B.Ramamurthy 20 AccountHome Interface import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.FinderException; import java.util.Collection; public interface AccountHome extends javax.ejb.EJBHome { //create methods Account create (String lastName, String firstName) throws RemoteException, CreateException, BadNameException; Account create (String lastName) throws RemoteException, CreateException; // find methods Account findByPrimaryKey (AccountKey primaryKey) throws RemoteException, FinderException; Collection findInActive(Date sinceWhen) throws RemoteException, FinderException, BadDateException;
  • 21. 5/27/2023 B.Ramamurthy 21 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; }
  • 22. 5/27/2023 B.Ramamurthy 22 AccountBean class public class AccountBean implements javax.ejb.EntityBean { // life cycle methods from home interface public AccountKey ejbCreate (String latName, String firstName) throws … {… public AccountKey ejbCreate(String lastName) throws …{…} public AccountKey ejbFindByPrimaryKey(AccountKey primarykey)… {…} Public Collection ejbFindInactive( Data sinecWhen).. {…} // business methods from remote interface public BigDecimal getBalance() {….} public void credit(BigDecimal amt) {…} Public void debit(BigDecimal amt) throws InsufficientFundException {….} // container callbacks from EntityBean container public ejbRemove( ) throws RemoveException{ …} public void setEntityContext(EntityContext ec) {…} public unsetEntityContext(EntityContext ec) {…} public void ejbActivate() {…} public void ejbLoad() {….} public void ejbStore() {….} }
  • 23. 5/27/2023 B.Ramamurthy 23 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>
  • 24. 5/27/2023 B.Ramamurthy 24 Summary J2EE environment provides a framework for bundling together the components into an application and provide the applications necessary common services such as persistence, security, mail, naming and directory service etc. Next class we will look a complete running example. Browse through:  http://java.sun.com/j2ee/faq.html  http://java.sun.com/blueprints/guidelines/designing_en terprise_applications_2e/index.html#chapters