Top Banner
Enterprise JavaBeans
89
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.

EnterpriseJavaBeans

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

Lesson 1:Introduction to Server-Side

Component Software

Page 3: Enterprise JavaBeans. 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

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

Client-Server andMulti-Tiered Architectures

Scalability

Extensibility

Security

Issues concerning distributed architectures

- Complexity

- Communication/bandwidth

- Maintenance costs

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

CentralizedMainframe Architecture

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

Two-TierArchitecture

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

Three-TierArchitecture

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

SoftwareComponents

Component architectures

- Component development tools

- Container

- Maintenance deployment tools

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

ComponentArchitecture Solutions

.NET Enterprise Architecture

CORBA

J2EE

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

J2EETechnologies

EJB

RMI/RMI-IIOP

JNDI

JDBC

JTA/JTS

JMS

JSP

IDL

JavaMail

Connectors

XML

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

EnterpriseJavaBeans

Differences between JavaBeans and Enterprise JavaBeans

EJB development tasks

- J2EE product provider

- Bean developer

- Application assembler

- Deployer

- System administrator

- Tool provider

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

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

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

Lesson 2:Overview of the Enterprise

JavaBeans Framework

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

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

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

EJBArchitecture

Primary components

- EJB-compliant server

- EJB-compliant container

- Home object (bean factory)

- EJB object (remote interface)

- EJB

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

Example ofEJB Architecture

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

Client Interactionwith EJBs

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

EJBContainer Services

Distributed transaction management

Persistence

Security

Component resource and life cycle management

Remote accessibility

Transparent location of components

Identification of components

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

The EJBHome Object

Location transparency

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

TheEJB Object

Stubs

Skeletons

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

Types ofEnterprise JavaBeans

Session beans

- Stateful

- Stateless

Entity beans

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

DeploymentDescriptors

An XML document that describes the properties of an EJB

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

TheEJB-JAR File

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

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

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

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

Lesson 3:Creating a

Session Bean

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

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

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

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

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

Creating theEnterprise Bean Class

ejbCreate methods

The SessionBean interface

The EJBContext interface

The SessionContext interface

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

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

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

Writing BusinessMethods for an EJB

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

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

TheHome Interface

Extends EJBHome

Provides mechanisms to create and remove EJB components

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

TheEJB Object

Extends the EJBObject interface

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

Exceptionsin EJB

System exceptions

Application exceptions

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

Example:A Session Bean

The Teller bean class

The Teller remote interface

The Teller home interface

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

The LibraryApplication

The Book entity bean

The Patron entity bean

The CheckOutRecord entity bean

The CheckOut session bean

The CheckIn session bean

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

LibraryDBSchema

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

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

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

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

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

Lesson 4:EJB Deployment

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

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

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

TheDeployment Descriptor

EJB requirements

DD XML tags

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

Environment Data

Environment property XML tags

Accessing environment data

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

Using JNDI

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

UsingBean References

EJB reference XML tags

Using the EJB reference

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

UsingResource Factories

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

EJB Deploymentin an EJB Server

Deploying an application

Creating stub and skeleton classes

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

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

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

Lesson 5:EJB Clients

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

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

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

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

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

Creatingan EJB Instance

Invocation of business methods

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

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

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

Lesson 6:Entity EJBs

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

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

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

What Isan Entity Bean?

Object serialization

Object-relational mapping

Bean-managed persistence

Container-managed persistence

Primary keys

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

Entity BeanArchitecture

Creating entity beans

Invoking business methods on entity beans

Swapping entity beans

Invoking remove() on an entity bean

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

Life Cycle of anEntity Bean Instance

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

Bean-ManagedPersistence

BMP

- SQL

- JDBC

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

EntityBean Methods

ejbCreate()

ejbPostCreate()

ejbRemove()

ejbLoad()

ejbStore()

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

UsingFinder Methods

ejbFindByPrimaryKey()

Multiple row finders

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

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

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

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

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

Lesson 7:Container-Managed

Persistence

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

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

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

Container-Managed Persistence

Benefits of CMP

- Less code needed

- Optimization techniques

- More portable

- Fewer bugs

Disadvantages of CMP

- Less flexibility

- Inaccessible code

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

ThePrimary Key

Primary key class

- Must be serializable

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

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

EJBMethods and CMP

ejbCreate()

ejbRemove()

ejbLoad()

ejbStore()

Other methods

Finder methods

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

The DDand CMP

Example: A CMP entity bean

- The EmployeeEJB bean class

- The home interface

- The remote interface

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

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

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

Lesson 8:Transactions

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

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

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

What Are Transactions?

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

Transactional management

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

Participantsin Transactions

Transactional objects or applications

Transaction managers

Resources

Resource managers

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

EJBTransactional Model

Flat transactional model

Nested transactional model

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

FlatTransactional Model

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

NestedTransactional Model

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

DistributedTransactions

Two-phase commits

Transparent transaction control

- Transaction context

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

IsolationLevels

Strict

- Each concurrent transaction is isolated from all other transactions

Nonstrict

- Increased transactional performance

- Possibility of corrupted data

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

Transactions in Enterprise JavaBeans

Transaction demarcation

Container-managed transactions

- Attributes

Defining CMT in the DD

Setting CMT in Deploytool

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

Bean-ManagedTransactions

UserTransaction interface

- Properties

- Methods

Setting BMT in the DD

BMT and stateful session beans

BMT and stateless session beans

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

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

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

Lesson 9:EJB Security

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

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

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

Defining Users,Principals and Roles

Overview of EJB security

- Authentication

- Authorization

Authorization in EJB code

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

Example: Users,Principals and Roles

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

Securityand the DD

The bean developer and the DD

The application assembler and the DD

The deployer and the DD

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

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

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

EnterpriseJavaBeans

Introduction to Server-Side Component Software

Overview of the Enterprise JavaBeans Framework

Creating a Session Bean

EJB Deployment

EJB Clients

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

EnterpriseJavaBeans

Entity EJBs

Container-Managed Persistence

Transactions

EJB Security