Docsity

Enterprise Java Beans - Lecture Slides | CS 6030, Study notes of Computer Science

Partial preview of the text

Download Enterprise Java Beans - Lecture Slides | CS 6030 and more Study notes Computer Science in PDF only on Docsity!

EnterpriseJavaBeans (EJB)

What are EJBs? „

They are components that can be connected toform a system

They can represent data

They can represent behavior

„

Usually, EJBs fall into only one of thesecategories

„

They are typically used in the server tier

„

EJBs can be persisted

„

EJBs can interact with other EJBs

EJB in the Big Picture of J2EE

EJB as Client/Server Middleware^ „

Think of EJBs as just another Client/Servermiddleware like RMI, CORBA, or Web Services

The EJB instance itself is the server

EJBs have clients (objects that call its methods)

„

One complication is that EJB clients can be:

Java Applets and Applications (using RMI or CORBA)

Non-Java applications (using CORBA)

JSPs and Servlets (using RMI or CORBA)

Other EJBs (using RMI or CORBA)

EJBs & 3-Tiered Architectures

Applet Web Page

Servlets & JSPs

EJBs

Database

Client Tier

Server Tier

Database Tier

In enterprise systems, EJB clients areusually: Servlets, JSPs, or Other EJBs

How EJBs Change Things

„

EJBs are most suitable for developing businesslogic and data manipulation

If all of the business logic operations and datamanipulations are done using EJBs, the JSPs andServlets will be focused mainly on displaying theresults of those operations

„

Session EJBs: Used to represent system behavior (i.e.business logic)

e.g. Storing products to purchase in the shopping cart

„

Entity EJBs: Used to represent & manipulate system data

e.g. Finding products that match a search term

Application Servers

„

Containers where EJBs (and JSPs and servlets)are executed

„

Provide EJB functionality, including:

Persistence through databases (using JDBC)

Transactions (using Java Transaction Service)

„

Can provide advanced features, including:

Load balancing

Database connection pooling

„

Here are the major application servers:

SJS AP, WebLogic (BEA), Internet ApplicationServer or iAS (Oracle), WebSphere (IBM)

Alternatives to EJBs „

CORBA objects provide some functionality similarto EJBs:

Persistence (of CORBA object data)

Transactions (between CORBA objects)

Security (between CORBA objects)

„

CORBA and EJBs are closely related, in fact, theyuse the same wire protocol:

IIOP

„

In some sense, EJBs can be considered to be anenhanced version of CORBA

Except that EJBs can only be created in Java

EJB Types

Subtypes of Session Beans „

Stateful:

Used for operations that require multiplerequests to be completed

Maintain data between requests

Stateless:

Used for operations that can be performed ina single request

Do not maintain persistent data betweensubsequent requests from a given client

Entity Beans Explained

„

Entity beans represent data in the system

In addition, entity beans are used to search for, modify, create anddelete data

Usually, this data resides in a relational database

Each entity bean typically represents a single row in some databasetable

„

An entity bean instance exists as long as the data is beingused

When the EJB client is done with the instance, the entity beaninstance usually returns to a bean pool

„

The client for an entity bean is typically a session bean, sincebehavior usually involves the manipulation of data

Session and Entity Beans

An EJB Autopsy

„

The remote interface

Describes the interface provided to EJB clients

„

The enterprise bean class

The implementation of the bean

„

The home interface

Describe

how client can create, find, and

remove EJB instances