89
Enterprise JavaBeans

Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software

Embed Size (px)

Citation preview

EnterpriseJavaBeans

Lesson 1:Introduction to Server-Side

Component Software

Objectives

Define client-server and multi-tier architecture

Discuss the benefits and issues of distributed architectures

Define software components

Discuss server-side component architecture and architecture solutions

Define J2EE technologies

Define EJB technology

Client-Server andMulti-Tiered Architectures

Scalability

Extensibility

Security

Issues concerning distributed architectures

- Complexity

- Communication/bandwidth

- Maintenance costs

CentralizedMainframe Architecture

Two-TierArchitecture

Three-TierArchitecture

SoftwareComponents

Component architectures

- Component development tools

- Container

- Maintenance deployment tools

ComponentArchitecture Solutions

.NET Enterprise Architecture

CORBA

J2EE

J2EETechnologies

EJB

RMI/RMI-IIOP

JNDI

JDBC

JTA/JTS

JMS

JSP

IDL

JavaMail

Connectors

XML

EnterpriseJavaBeans

Differences between JavaBeans and Enterprise JavaBeans

EJB development tasks

- J2EE product provider

- Bean developer

- Application assembler

- Deployer

- System administrator

- Tool provider

Summary

Define client-server and multi-tier architecture

Discuss the benefits and issues of distributed architectures

Define software components

Discuss server-side component architecture and architecture solutions

Define J2EE technologies

Define EJB technology

Lesson 2:Overview of the Enterprise

JavaBeans Framework

Objectives

Define an EJB server’s main components

Discuss EJB and client interaction

Identify EJB container services

Describe home objects and EJB objects

Compare session beans and entity beans

Define a deployment descriptor

Identify the EJB JAR file

EJBArchitecture

Primary components

- EJB-compliant server

- EJB-compliant container

- Home object (bean factory)

- EJB object (remote interface)

- EJB

Example ofEJB Architecture

Client Interactionwith EJBs

EJBContainer Services

Distributed transaction management

Persistence

Security

Component resource and life cycle management

Remote accessibility

Transparent location of components

Identification of components

The EJBHome Object

Location transparency

TheEJB Object

Stubs

Skeletons

Types ofEnterprise JavaBeans

Session beans

- Stateful

- Stateless

Entity beans

DeploymentDescriptors

An XML document that describes the properties of an EJB

TheEJB-JAR File

Contains the class files for a bean, its home and remote interfaces, and the deployment descriptors

Summary

Define an EJB server’s main components

Discuss EJB and client interaction

Identify EJB container services

Describe home objects and EJB objects

Compare session beans and entity beans

Define a deployment descriptor

Identify the EJB JAR file

Lesson 3:Creating a

Session Bean

Objectives

Define the methods of the SessionBean interface

Describe the EJBContext and the SessionContext interfaces

Contrast stateful and stateless session beans

Explain how to write business methods for a session bean

Discuss the EJB life cycle

Objectives (cont’d)

Create a session bean

Define the EJBHome and EJBObjects interfaces and their methods

Discuss the superclass for the home and remote interfaces

Describe system and application exceptions

Deploy and connect to a session bean

Creating theEnterprise Bean Class

ejbCreate methods

The SessionBean interface

The EJBContext interface

The SessionContext interface

Stateless andStateful Session Beans

Stateless session beans

- Do not keep track of any information from one method call to the next

Stateful session beans

- Can change their state during a conversation with a client

Writing BusinessMethods for an EJB

Each EJB must declare the business methods that define the work that the EJB is designed to perform

TheHome Interface

Extends EJBHome

Provides mechanisms to create and remove EJB components

TheEJB Object

Extends the EJBObject interface

Exceptionsin EJB

System exceptions

Application exceptions

Example:A Session Bean

The Teller bean class

The Teller remote interface

The Teller home interface

The LibraryApplication

The Book entity bean

The Patron entity bean

The CheckOutRecord entity bean

The CheckOut session bean

The CheckIn session bean

LibraryDBSchema

Summary

Define the methods of the SessionBean interface

Describe the EJBContext and the SessionContext interfaces

Contrast stateful and stateless session beans

Explain how to write business methods for a session bean

Discuss the EJB life cycle

Summary (cont’d)

Create a session bean

Define the EJBHome and EJBObjects interfaces and their methods

Discuss the superclass for the home and remote interfaces

Describe system and application exceptions

Deploy and connect to a session bean

Lesson 4:EJB Deployment

Objectives

Define a deployment descriptor

Add environment data to a DD

Describe how to reference resource factories in a DD

Explain assembly information in a DD

Use JNDI to access an EJB’s environment data

Describe the process of EJB deployment

TheDeployment Descriptor

EJB requirements

DD XML tags

Environment Data

Environment property XML tags

Accessing environment data

Using JNDI

UsingBean References

EJB reference XML tags

Using the EJB reference

UsingResource Factories

EJB Deploymentin an EJB Server

Deploying an application

Creating stub and skeleton classes

Summary

Define a deployment descriptor

Add environment data to a DD

Describe how to reference resource factories in a DD

Explain assembly information in a DD

Use JNDI to access an EJB’s environment data

Describe the process of EJB deployment

Lesson 5:EJB Clients

Objectives

Use JNDI to obtain a reference to the home object

Instantiate an EJB instance using the home object

Call an EJB’s business methods

Remove an EJB

Write an EJB client

Using JNDI

JDNI is an API

- Used to access naming and directory services

- Provides an interface to the RMI registry

JNDI InitialContext

Locating the home object

Creatingan EJB Instance

Invocation of business methods

Summary

Use JNDI to obtain a reference to the home object

Instantiate an EJB instance using the home object

Call an EJB’s business methods

Remove an EJB

Write an EJB client

Lesson 6:Entity EJBs

Objectives

Discuss entity beans and their persistence management techniques

Identify the methods of the EntityBean and EntityContext interfaces

Define primary keys and describe their use

Describe the mechanics of entity beans

Use finder methods

Write an entity bean and its interfaces

What Isan Entity Bean?

Object serialization

Object-relational mapping

Bean-managed persistence

Container-managed persistence

Primary keys

Entity BeanArchitecture

Creating entity beans

Invoking business methods on entity beans

Swapping entity beans

Invoking remove() on an entity bean

Life Cycle of anEntity Bean Instance

Bean-ManagedPersistence

BMP

- SQL

- JDBC

EntityBean Methods

ejbCreate()

ejbPostCreate()

ejbRemove()

ejbLoad()

ejbStore()

UsingFinder Methods

ejbFindByPrimaryKey()

Multiple row finders

The Remote Interface and the Home Interface

Remote interface

- Provides the interface for the client

- Exposes methods for manipulating the entity bean

Home interface

- Contains the create() and find…() methods for an entity bean

Summary

Discuss entity beans and their persistence management techniques

Identify the methods of the EntityBean and EntityContext interfaces

Define primary keys and describe their use

Describe the mechanics of entity beans

Use finder methods

Write an entity bean and its interfaces

Lesson 7:Container-Managed

Persistence

Objectives

Discuss entity beans and CMP

Explain the benefits and disadvantages of using CMP

Describe the primary key as it relates to CMP

Define an ejbCreate() method that uses CMP

Write the requisite methods for an entity bean to use CMP

Container-Managed Persistence

Benefits of CMP

- Less code needed

- Optimization techniques

- More portable

- Fewer bugs

Disadvantages of CMP

- Less flexibility

- Inaccessible code

ThePrimary Key

Primary key class

- Must be serializable

- Must be of a legal value type in RMI-IIOP

EJBMethods and CMP

ejbCreate()

ejbRemove()

ejbLoad()

ejbStore()

Other methods

Finder methods

The DDand CMP

Example: A CMP entity bean

- The EmployeeEJB bean class

- The home interface

- The remote interface

Summary

Discuss entity beans and CMP

Explain the benefits and disadvantages of using CMP

Describe the primary key as it relates to CMP

Define an ejbCreate() method that uses CMP

Write the requisite methods for an entity bean to use CMP

Lesson 8:Transactions

Objectives

Define transactions and explain their use

Distinguish transaction participants

Define transaction properties

Explain the EJB transactional model

Describe distributed transactions

Define transaction isolation levels

Discuss EJB transaction attributes

What Are Transactions?

Operations or series of operations that are treated as single units of work

Transactional management

Participantsin Transactions

Transactional objects or applications

Transaction managers

Resources

Resource managers

EJBTransactional Model

Flat transactional model

Nested transactional model

FlatTransactional Model

NestedTransactional Model

DistributedTransactions

Two-phase commits

Transparent transaction control

- Transaction context

IsolationLevels

Strict

- Each concurrent transaction is isolated from all other transactions

Nonstrict

- Increased transactional performance

- Possibility of corrupted data

Transactions in Enterprise JavaBeans

Transaction demarcation

Container-managed transactions

- Attributes

Defining CMT in the DD

Setting CMT in Deploytool

Bean-ManagedTransactions

UserTransaction interface

- Properties

- Methods

Setting BMT in the DD

BMT and stateful session beans

BMT and stateless session beans

Summary

Define transactions and explain their use

Distinguish transaction participants

Define transaction properties

Explain the EJB transactional model

Describe distributed transactions

Define transaction isolation levels

Discuss EJB transaction attributes

Lesson 9:EJB Security

Objectives

Define users in EJB security

Discuss principals in EJB security

Identify roles in EJB security

Describe the DD’s role in EJB security

Explain the EJB container’s role in EJB security

Defining Users,Principals and Roles

Overview of EJB security

- Authentication

- Authorization

Authorization in EJB code

Example: Users,Principals and Roles

Securityand the DD

The bean developer and the DD

The application assembler and the DD

The deployer and the DD

Summary

Define users in EJB security

Discuss principals in EJB security

Identify roles in EJB security

Describe the DD’s role in EJB security

Explain the EJB container’s role in EJB security

EnterpriseJavaBeans

Introduction to Server-Side Component Software

Overview of the Enterprise JavaBeans Framework

Creating a Session Bean

EJB Deployment

EJB Clients

EnterpriseJavaBeans

Entity EJBs

Container-Managed Persistence

Transactions

EJB Security