Full HTML for

Basic foilset Enterprise Javabeans

Given by Nancy McCracken at Basic Information Track Computational Science Course CPS616 on Spring Semester 1999. Foils prepared May 19 99
Outside Index Summary of Material


Overview of Enterprise Javabeans with discussion of goals, architecture
Interaction with databases
EJB Containers, Servers, Components, Session Beans,Entity Beans
Users of EJB's and how to write them
Shopping Cart Examples

Table of Contents for full HTML of Enterprise Javabeans

Denote Foils where Image Critical
Denote Foils where Image has important information
Denote Foils where HTML is sufficient
denotes presence of Additional linked information which is greyed out if missing

1 Enterprise JavaBeans
2 Suns Enterprise Java Beans page Enterprise JavaBeans
3 Goals of Enterprise JavaBeans
4 Development of EJB
5 EJB Architecture
6 Architecture Diagram
7 EJB Containers
8 EJB Servers
9 EJB Components
10 Session and Entity Beans
11 EJB Technology Features
12 Five roles for people using EJB
13 How to write EJBeans
14 EJB Tools
15 Shopping Cart Basic Application
16 Advanced Shopping Cart Scenario
17 Remote Interface
18 Business Logic
19 Home Interface
20 Deployment Descriptor
21 Deploy EJBean
22 Client-side code gets EJBHome
23 Client code creates and calls
24 Future of EJB
25 Positioning of Technologies
26 More detailed Resources

Outside Index Summary of Material



HTML version of Basic Foils prepared May 19 99

Foil 1 Enterprise JavaBeans

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Nancy McCracken
Northeast Parallel Architectures Center
Syracuse University
111 College Place
Syracuse, NY 13244-4100
April 1999

HTML version of Basic Foils prepared May 19 99

Foil 2 Enterprise JavaBeans

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index Suns Enterprise Java Beans page
Enterprise JavaBeans is the architecture for a server-side platform that provides distributed components.
  • "a standard for multi-tier, server-oriented, component development".
Resources:
  • "An Introduction to Enterprise JavaBeans Technology, by Bill Roth, Engineering Program Manager for EJB at Sun Microsystems, Java Report, October 1998.
  • http://www.javasoft.com/products/ejb/ has many resources including
    • EJB White Paper by Anne Thomas
    • EJB Learning Center
    • EJB tutorial at the Java Developer Connection

HTML version of Basic Foils prepared May 19 99

Foil 3 Goals of Enterprise JavaBeans

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Allow application developer to concentrate on business logic, instead of systems details of distributed systems, transaction logic, database access, security, scalability and integration with existing systems.
Cross-platform capability - using Java means "write once run anywhere".
Logical extension of JavaBeans component programming.
Existing non-Java enterprise applications can be used as components.
Certain behaviors such as security and transactions should be set as properties of the component, instead of hand-programmed.

HTML version of Basic Foils prepared May 19 99

Foil 4 Development of EJB

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
The EJB 1.0 specification was publicly released during the JavaOne `98 conference.
Partners with Sun in developing the specification:
  • Sybase
  • BEA
  • Oracle
  • IBM
  • Netscape
  • Novell
  • Tandem
  • Others

HTML version of Basic Foils prepared May 19 99

Foil 5 EJB Architecture

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
The EJB architecture consists of a server which may run instances of JavaBeans inside of a container, clients of any kind, connected via any protocol.
  • Clients can be written in any language
  • The server can support multiple protocols like RMI, IIOP and DCOM.
The EJB specification is for the collection of services that the server should provide.
  • management of distributed transactions
  • management of distributed objects and invocations of these objects
  • low-level system services such as thread synchronization, security
  • naming, remote access

HTML version of Basic Foils prepared May 19 99

Foil 6 Architecture Diagram

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Container
EJB Server
EJB Object
(bean id)
Database
Or
TP Monitor
business
methods
create, find, remove

HTML version of Basic Foils prepared May 19 99

Foil 7 EJB Containers

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
A container is the "EJBHome" for EJB components.
The container provides the secure, transactional environment.
It manages the object life cycle of the bean (component), and the state management.
The container provides the implementation of the bean's EJBHome interface and Remote interface.
It is responsible for making the Bean's EJBHome interface available in JNDI, the Java Naming and Directory Interface.

HTML version of Basic Foils prepared May 19 99

Foil 8 EJB Servers

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
An EJB Server provider must provide an implementation of a container. Many vendors simply adapt existing application servers.
Vendors of EJB Servers:
  • BEA WebLogic Tengah
  • NetDynamics
  • IBM WebSphere Advanced Edition
  • Oracle8i, Oracle Application Server
  • Persistence Power Tier
  • Progress Apptivity
  • Forte, Informix, Netscape, Gemstone, Bluestone, Inprise
  • and many others . . .

HTML version of Basic Foils prepared May 19 99

Foil 9 EJB Components

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Database is source of potential objects
EJB technology takes these objects to a multi-tier environment
Two models for building enterprise applications:
  • Session model: the client begins a session with an object that acts like an application, executing a unit of work on behalf of the client, possibly including multiple database transactions.
  • Entity model: the client accesses an object that represents an entity in the database.

HTML version of Basic Foils prepared May 19 99

Foil 10 Session and Entity Beans

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Session Beans:
  • Fields contain conversation state
  • Typically reads/writes database for client
  • Life of client is life of bean
  • Can be transaction aware
  • Do not survive server crashes
Entity Beans:
  • Represent data in a database
  • Transactional
  • Share access for multiple users
  • Long-lived: as long as data in database
    • tyical of object-oriented databases
  • Survive server crashes.

HTML version of Basic Foils prepared May 19 99

Foil 11 EJB Technology Features

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Many behaviors can be specified in the Deployment Descriptor object of each container.
Transaction management properties: no longer write transaction demarcation in the code - container will implicitly use one of six transaction rules.
  • EJB spec suggests, but not requires, you to use Java Transaction Service (JTS) API, the Java binding of the CORBA Object Transaction Service.
Security: security rules for each bean are defined in a set of AccessControlEntry objects within the deployment descriptor.
  • Defines a list of users allowed to access each method
  • Or the user may choose to manage their own security programmatically with the java.security package.
A bean may be moved to any EJB server (for example, for performance reasons).

HTML version of Basic Foils prepared May 19 99

Foil 12 Five roles for people using EJB

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Server provider - typically a database or TP vendor, transaction processing, distributed objects.
Container provider - also typically a DB or TP vendor, systems programming and interfaces to existing applications.
Enterprise bean provider - domain experts who provide business logic in building block beans.
Application assemblers: domain experts who assemble beans and provide user interface
Deployers: DBAs, or other persons familiar with application environment.

HTML version of Basic Foils prepared May 19 99

Foil 13 How to write EJBeans

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
0. Design code
1. Write business methods (can use an IDE like Sun's Java Workshop, Symantec's Café, or Inprise's Jbuilder).
2. Write* remote interface -- EJBObject
3. Write* home interface -- EJBHome
4. Create and Install EJB-JAR in container
5. Debug & Test

HTML version of Basic Foils prepared May 19 99

Foil 14 EJB Tools

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Business
Model
Class
Design
EJB-JAR
file
EJB-JAR,
Factory,
Environment &
Deployment descriptors
Design Time
Run Time

HTML version of Basic Foils prepared May 19 99

Foil 15 Shopping Cart Basic Application

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Clients
Web Server
Java Mid-Tier
Server
Shopping
Cart
Credit Card
Order Entry
EJB Server
DBMS
EJB Container

HTML version of Basic Foils prepared May 19 99

Foil 16 Advanced Shopping Cart Scenario

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Clients
Web Server
Existing
Enterprise
Middleware
Standard
Container
Shopping
Cart
Credit Card
CICS Container
SAP Container
Order Entry
CICS Programs
SAP Modules
EJB Server

HTML version of Basic Foils prepared May 19 99

Foil 17 Remote Interface

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
public interface ShoppingCart extends
javax.ejb.EJBObject
{
boolean addItem(int itemNumber)
throws java.rmi.RemoteException;
boolean purchase()
throws java.rmi.RemoteException;
}
Define the interface to the methods that the clients can call. Note that methods must conform to RMI standards in that parameters must be Serializable and methods must throw rmi.RemoteException. But RMI is being extended to support IIOP protocol, and hence COM.

HTML version of Basic Foils prepared May 19 99

Foil 18 Business Logic

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
public class ShoppingCartEJB
implements SessionBean
{
public boolean addItem(int itemNumber) {
// the code for adding items to the cart
// may include JDBC™ code.
}
public boolean purchase () {
// the code for purchases
}
public void ejbCreate(String accountName,
String account) {
// object initialization code
}
}

HTML version of Basic Foils prepared May 19 99

Foil 19 Home Interface

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
public interface CartHome extends
javax.ejb.EJBHome
{
  • Cart create(String customerName,
  • String account)
    • throws RemoteException,
    • BadAccountException;
}
Note that on previous slide, server bean did not implement the Remote interface. The server creates this EJBObject and also the EJBHome, corresponding to the following interface. Note that this create will call the EJBcreate method of the bean.

HTML version of Basic Foils prepared May 19 99

Foil 20 Deployment Descriptor

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Class SessionDescriptor
public class javax.ejb.deployment.SessionDescriptor
extends javax.ejb.deployment.DeploymentDescriptor
{
public final static int STATEFUL_SESSION;
public final static int
STATELESS_SESSION;
public SessionDescriptor();
public int getSessionTimeout();
public int getStateManagementType();
public void setSessionTimeout(int value);
public void setStateManagementType(int value);
}

HTML version of Basic Foils prepared May 19 99

Foil 21 Deploy EJBean

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
To deploy an Enterprise JavaBean, make a .jar file with the code and the deployment descriptor.
The deployment person (aka dba) will put the code in a place known to the server and do other housekeeping details depending on the server, such as editing a properties file of all the EJBeans on the server.

HTML version of Basic Foils prepared May 19 99

Foil 22 Client-side code gets EJBHome

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Context initialContext = new InitialContext();
CartHome cartHome = (CartHome)
initialContext.lookup
("applications/mall/shopping-carts");
Client-side code may be written in Java in an applet, application or servlet, or in a C++ application using CORBA.
Getting the home of the remote bean:
  • InitialContext gets the root of the JNDI naming hierarchy
  • lookup method gets the instance of CartHome wanted (from a known JNDI path).
  • The actual container and server are transparent to the user - a container can be on several servers.

HTML version of Basic Foils prepared May 19 99

Foil 23 Client code creates and calls

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
The variable cart contains a reference to the remote EJBObject, which is created by create. This example creates a new session bean. The reference to the EJBObject is used to call the remote methods.
ShoppingCartEJB cart =
cartHome.create("Emma", "0507");
cart.addItem(100);
cart.addItem(251);
cart.purchase();

HTML version of Basic Foils prepared May 19 99

Foil 24 Future of EJB

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Bill Roth suggests that we view this 1.0 specification as the first iteration in a process of developing EJB.
Some of the areas that need to be refined:
  • model for handling persistent objects
  • standardizing contract between development tools and systems to provide a uniform debugging interface
Wide industry participation - but need to make sure that EJB servers from different vendors can interoperate.
Most notable holdout: Microsoft. Microsoft supports the Microsoft Transaction Server (MTS) and is not likely to make it interoperable with EJB's.

HTML version of Basic Foils prepared May 19 99

Foil 25 Positioning of Technologies

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
complexity
capability
EJB
MTS
CORBA
2 days
2 weeks
transactions
threading
security
persistence
platform independence
scalability
ease of use
safety

HTML version of Basic Foils prepared May 19 99

Foil 26 More detailed Resources

From Enterprise Javabeans Basic Information Track Computational Science Course CPS616 -- Spring Semester 1999. *
Full HTML Index
Detailed tutorial using free downloadable BEA WebLogic Tengah server:
"A beginner's guide to Enterprise JavaBeans" by Mark Johnson of JavaWorld has many more references at the bottom of the article:

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Mon Jul 5 1999