ejb by: sirisha panchagnula dt:11/04/03

24
EJB EJB By: Sirisha By: Sirisha Panchagnula Panchagnula Dt:11/04/03 Dt:11/04/03

Upload: ranee

Post on 12-Jan-2016

77 views

Category:

Documents


4 download

DESCRIPTION

EJB By: Sirisha Panchagnula Dt:11/04/03. Introduction Why EJB? When To Use EJB? Where does EJB Run? Differences between Java beans &EJB Basic EJB Architecture What Does EJB Consist? EJB Architecture Revisited EJB Components EJB Container for Session N Entity Beans. Types of EJB’s - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: EJB By: Sirisha Panchagnula Dt:11/04/03

EJBEJBBy: Sirisha By: Sirisha

PanchagnulaPanchagnula

Dt:11/04/03Dt:11/04/03

Page 2: EJB By: Sirisha Panchagnula Dt:11/04/03

IndexIntroductionWhy EJB?When To Use EJB?Where does EJB Run?Differences between Java beans &EJBBasic EJB ArchitectureWhat Does EJB Consist?EJB Architecture RevisitedEJB ComponentsEJB Container for Session N Entity Beans

Types of EJB’sEJB With Session & Entity BeansWhat is Entity Bean?Persistence in Entity BeanWhat is Session Bean?Stateful & Stateless BeansEntity Bean Vs Session BeanLife Cycle Of EJBRoles In EJB Cycle

Page 3: EJB By: Sirisha Panchagnula Dt:11/04/03

Introduction

Enterprise Java Beans is a specification for creating server-side scalable, transactional, multi-user secure enterprise-level applications. It provides a consistent component architecture framework for creating distributed n-tier middleware. EJB enables rapid and simplified development of distributed, transactional, secure and portable Java applications.

Page 4: EJB By: Sirisha Panchagnula Dt:11/04/03

Why Enterprise Java Beans?

Architectural Independence for developers WORA (Write Once, Run Anywhere) for server side components (Portable Components)Establishes roles for application development Takes care of Transaction Management Provides Distributed Transaction support Helps create Portable & Scalable solutions Integrates seamlessly with CORBA Provides vendor specific enhancements.Location Transparent

Page 5: EJB By: Sirisha Panchagnula Dt:11/04/03

When To Use EJB?

Applications should be scalableApplications that contain business logic that operates on Enterprise’s data.Transactions should ensure data integrityApplications should have variety of clients.Clients can be thin & numerous.

Page 6: EJB By: Sirisha Panchagnula Dt:11/04/03

Where Does EJB Run?

Page 7: EJB By: Sirisha Panchagnula Dt:11/04/03

                                                                                 

                                              

Page 8: EJB By: Sirisha Panchagnula Dt:11/04/03

Differences Between Java Beans & EJB’s

Can be either visible or non-visible

Are decidedly Non-Visible, remote objects

Intended to be local to a single process on the client side

Remotely executable components deployed on the server

Uses the BeanInfo classes, Property Editors & Customizers to describe itself

Uses the Deployment Descriptor to

describe itself.

Can also be deployed as an

ActiveX control Cannot be deployed as an ActiveX control since OCXs run on the desktop

Page 9: EJB By: Sirisha Panchagnula Dt:11/04/03

BASIC EJBBASIC EJB ARCHITECTUREARCHITECTURE

Page 10: EJB By: Sirisha Panchagnula Dt:11/04/03

What Does EJB Consist

• A typical EJB Architecture consists of ** An EJB server, An EJB server, * * EJB containers that runs on these servers,EJB containers that runs on these servers, * * EJBs that run in these containers, EJBs that run in these containers, * * EJB clients and other auxiliary systems like EJB clients and other auxiliary systems like the the Java Naming and Directory Interface (JNDI),Java Transaction Server(JTS)(JNDI),Java Transaction Server(JTS)

* * The EJB Home interface and Home objectThe EJB Home interface and Home object

* * The Remote interface and EJBObjectThe Remote interface and EJBObject

Page 11: EJB By: Sirisha Panchagnula Dt:11/04/03

EJB Architecture Revisited

Page 12: EJB By: Sirisha Panchagnula Dt:11/04/03

EJB ComponentsEJB Servers :Analogous to the CORBA ORB.Provides the system services like ( raw execution environment), ( multiprocessing), ( load-balancing ) , ( device access ) Provides naming transaction servicesMakes containers visible.EJB ClientsEJB Clients :Use EJB Beans for their operations. Find the EJB container that contains the bean through the Java Naming and Directory (JNDI) interface. Use the EJB Container to invoke EJB Bean methods.EJB Containers :Act as the interface between an Enterprise Java Bean and the outside world. EJB client never accesses a bean directly.

Page 13: EJB By: Sirisha Panchagnula Dt:11/04/03

Components Con’tAny bean access is done through container-generated methods which in turn invoke the bean's methods. The EJB Home interface and Home objectThe EJB Home interface and Home object :Factory methods for (locating) (creating) (removing instances of EJB classes) are defined here.The Home object is the implementation of the Home interface The Remote interface and EJBObject:The Remote interface and EJBObject:Lists the business methods available for the enterprise Bean.The EJBObject is the client’s view of the enterprise Bean It implements the remote interface.The Enterprise Java Bean:The Enterprise Java Bean:The real EJB Bean itself is contained within an EJB container, and should never be directly accessed other than the container.

Page 14: EJB By: Sirisha Panchagnula Dt:11/04/03

EJB Container For Session & Entity Beans

Page 15: EJB By: Sirisha Panchagnula Dt:11/04/03

Types Of EJB’s

Enterprise Bean Type

Purpose

Session Performs a task for a client

Entity Represents a business entity object that exists in persistent storage

Message-Driven Acts as a listener for the Java Message Service API, processing messages asynchronously

Page 16: EJB By: Sirisha Panchagnula Dt:11/04/03

EJB Environment With Session & Entity Beans

Page 17: EJB By: Sirisha Panchagnula Dt:11/04/03

What is Entity BeanEntity Beans always have states.Can be shared by multiple EJB Clients.Their states can be persisted and stored across multiple invocations. Hence they can survive System Shutdowns.EJB servers have a right to manage their working set.Passivation is the process by which the state of a Bean is saved to persistent storage and then is swapped out. Activation is the process by which the state of a Bean is restored by swapping it in from persistent storage. Passivation and Activation apply to both Session and Entity Beans

Page 18: EJB By: Sirisha Panchagnula Dt:11/04/03

Persistance in Entity BeansPersistence in Entity Beans is of two types. They are:Container-managed persistence:Here, the EJB container is responsible for saving the Bean's state. Hence the implementation is independent of the data source. Bean-managed persistence:Entity bean directly responsible for saving its own state. Implementation less adaptable than the previous one.

Page 19: EJB By: Sirisha Panchagnula Dt:11/04/03

What Is Session Bean?

As its name suggests, a session bean is similar to an interactive session. A session bean is not shared Like an interactive session, a session bean is not persistentThere are two types of session beans: stateful and stateless. Stateless Session Beans:These types of EJBs have no internal state. Since they do not have any states, they need not be passivatedBecause of the fact that they are stateless, they can be pooled to

service multiple clients

Page 20: EJB By: Sirisha Panchagnula Dt:11/04/03

Stateful Session Beans

These have internal states. Hence need to handle Activation and Passivation. Also called Persistent Session Beans. These types of EJBs can be saved and restored across client sessions.To save, a call to the bean's getHandle() method returns a handle object. To restore call getEJBObject() method

Page 21: EJB By: Sirisha Panchagnula Dt:11/04/03

Entity Bean Vs Session BeanSession Bean Entity Bean

The data members of the session bean contain conversational state.conversational state.

The data members of the entity bean represent actual data in the domain model.

A session bean may handle database access for a single client.single client.

Entity beans share database access for multiple clients.multiple clients.

Because session beans are about a conversation with a single client, session beans are allowed to store per-client state store per-client state information..information..

Because entity beans are shared between multiple clients, they do not allow storagedo not allow storage of per-client state information.

The relationship between a session bean and its client is one-to-one.one-to-one.

The relationship between an entity bean and a row in the domain model is one-to-one.

The life life of the session bean is limited limited to the life of its client.

An entity bean persists persists as long as the data exists in the database.

Session beans can be transaction aware.transaction aware. Entity beans are transactionalare transactional.

Session beans do not survivedo not survive server crashes. Entity beans survive server crashessurvive server crashes. 

Page 22: EJB By: Sirisha Panchagnula Dt:11/04/03

Life Cycle Of EJB

Page 23: EJB By: Sirisha Panchagnula Dt:11/04/03

Roles in EJB Cycle

EJBEJB Bean ProviderBean Provider –Developers who create enterprise beans

Application AssemblerApplication Assembler - uses the EJB

EJB DeployerEJB Deployer - deploys the EJBs on a Server

EJB Server ProviderEJB Server Provider - creates EJB Servers

EJB Container ProviderEJB Container Provider - creates EJB containers and tools

System AdminSystem Admin : Ensures server is available to other network services Ensures the servers are configured correctly to handle user loads.

Page 24: EJB By: Sirisha Panchagnula Dt:11/04/03

ReferencesReferences

http://my.execpc.com/~gopalan/

Java FAQ

Ejb Concepts by Sun