Presentation is loading. Please wait.

Presentation is loading. Please wait.

EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.

Similar presentations


Presentation on theme: "EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications."— Presentation transcript:

1 EJB

2 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.

3 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

4 When To Use EJB? Applications should be scalable Applications that contain business logic that operates on Enterprise’s data. Transactions should ensure data integrity Applications should have variety of clients. Clients can be thin & numerous.

5 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

6 EJBARCHITECTURE EJB ARCHITECTURE

7 What Does EJB Consist * An EJB server, * EJB containers that runs on these servers, * EJBs that run in these containers, * EJB clients and other auxiliary systems like the Java Naming and Directory Interface (JNDI),Java Transaction Server(JTS)A typical EJB Architecture consists of * An EJB server, * EJB containers that runs on these servers, * EJBs that run in these containers, * EJB clients and other auxiliary systems like the Java Naming and Directory Interface (JNDI),Java Transaction Server(JTS)Java Naming and Directory InterfaceEJB ArchitectureJava Naming and Directory Interface * The EJB Home interface and Home object * The EJB Home interface and Home object * The Remote interface and EJBObject * The Remote interface and EJBObject

8 EJB Architecture Revisited

9 EJB Components EJB Servers EJB ServersEJB Servers EJB Servers : Analogous to the CORBA ORB. Provides the system services like ( raw execution environment), ( multiprocessing), ( load-balancing ), ( device access ) Provides naming transaction services Makes containers visible. EJB Clients EJB 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 EJB ContainersEJB Containers EJB Containers : Act as the interface between an Enterprise Java Bean and the outside world. EJB client never accesses a bean directly.

10 Components Con’t Any bean access is done through container-generated methods which in turn invoke the bean's methods. The EJB Home interface and Home object The 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: 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.

11 EJB Container For Session & Entity Beans

12 Types Of EJB’s Enterprise Bean Type Purpose SessionPerforms a task for a client EntityRepresents a business entity object that exists in persistent storage Message-DrivenActs as a listener for the Java Message Service API, processing messages asynchronously

13 EJB Environment With Session & Entity Beans

14 What is Entity Bean Entity 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

15 Persistance in Entity Beans Persistence 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.

16 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 persistent There 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 passivated Because of the fact that they are stateless, they can be pooled to service multiple clients

17 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

18 Entity Bean Vs Session Bean Session BeanEntity Bean conversational state. The data members of the session bean contain conversational state. The data members of the entity bean represent actual data in the domain model. single client. A session bean may handle database access for a single client. multiple clients. Entity beans share database access for multiple clients. store per-client state information.. Because session beans are about a conversation with a single client, session beans are allowed to store per-client state information.. do not allow storage Because entity beans are shared between multiple clients, they do not allow storage of per-client state information. one-to-one. The relationship between a session bean and its client is one-to-one. The relationship between an entity bean and a row in the domain model is one-to-one. life limited The life of the session bean is limited to the life of its client. persists An entity bean persists as long as the data exists in the database. transaction aware. Session beans can be transaction aware. are transactional Entity beans are transactional. do not survive Session beans do not survive server crashes. survive server crashes Entity beans survive server crashes.

19 Life Cycle Of EJB

20 Roles in EJB Cycle EJBBean Provider EJB Bean Provider –Developers who create enterprise beans Application Assembler Application Assembler - uses the EJB EJB Deployer EJB Deployer - deploys the EJBs on a Server EJB Server Provider EJB Server Provider - creates EJB Servers EJB Container Provider EJB Container Provider - creates EJB containers and tools System Admin System Admin : Ensures server is available to other network services Ensures the servers are configured correctly to handle user loads.


Download ppt "EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications."

Similar presentations


Ads by Google